-
-
Notifications
You must be signed in to change notification settings - Fork 13
Implement context IsEmpty check #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi. Thanks for the consideration. It doesn't sound good that you get callbacks after the context has been closed. Since closing the context frees tracked values, this feels like it could lead to undefined behavior. I think adding this function may make it feel safe to not care about the Context lifetime, which is absolutely not the case. |
Yes, context lifetimes are a valid and serious point. Solution could be implementation of event loop, entire event loop system just to run Please consider function You've mentioned that closing frees tracked values. What about introducing finalizers for ContextPtr (or even go-world Context). That way developer could call One other way could be adopting |
I think there's something that should be made very clear, v8go is a Go adapter of the V8 engine, which is itself an ECMAScript execution engine. V8 itself doesn't run concurrently, and will segfault if client code tries to do so in the same Isolate. So while I'm not sure what problem you're trying to solve, it appears to be something you need to control on the caller side. And if you want to add an event loop on top, you need to deal with synchronizing shutdown in client code. E.g., in a browser, the event loop runs in the main thread, so JS code can never run concurrently with any DOM modifications triggered by user interaction; including shutdown. |
Thanks for the explanation. Since the only way to free a context is for the caller to issue (Side-note: v8 |
Hey,
this implements IsEmpty check.
It tells developer if context was Reset, freed or what you call here in v8go - closed.
It's useful for checking during callbacks whether context is still alive - so whether JS callback function still lives.
Note: It's a direct dependency of my upcoming PR in https://github.com/kuoruan/v8go-polyfills
Thanks for this brilliant fork, please consider making it a separate repo ;)