-
Notifications
You must be signed in to change notification settings - Fork 177
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
help: pattern to create/destroy v7 instances? #557
Comments
Yes it's ok; probably not the most efficient way, but it really depends on the application.
v7 is not thread-safe; so, if you need to reuse the same v7 instance in different threads, you must provide proper synchronization. Or, you might want to have a separate v7 instance for each thread; then, they can work in parallel, but keep in mind that if you have some JS value ( |
just a clarification/nitpick: you cannot use the same v7 instance concurrently by different threads. You can keep a pool of v7 instances and have a thread use one v7 context for a bit, put it back in the pool and later have another thread use it for a while. There are some libraries (zeromq springs to my mind) that don't allow you to do that (forcing you to create and use a given context from the same thread), hence the clarification. Implementation note: currently numbers, booleans, null, undefined and short strings (<=5 chars) are completely stored in the However relying on this behaviour is unsupported. We might change the underlying implementation at any time. All the
|
I am wondering if there is a good pattern to create and destroy multiple instance of v7?
Is this ok to to create/destroy an instance each time we want to execute a function in a job? Can we reuse the instance in different threads? For example maintaining a pool of instance ? Or better to have a pool of workers?
The text was updated successfully, but these errors were encountered: