-
Notifications
You must be signed in to change notification settings - Fork 142
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
Allow to require external node modules in a thread #22
Comments
I agree. |
Too. |
Likewise, a much needed feature |
I would really like this as well. |
I agree too. |
@thomasfr can you describe what you had in mind? This library comes closest to implementing what I want with the exception of this feature, and I have the time right now to work on it. |
Hi, it is some time ago since i opened that issue, but it would be still very very helpful. I think i was missing the option to use external modules like |
I noticed that you can't include any core module. I wasn't sure what you meant by starting a thread with a larger context. I'm fairly new to node native bindings. |
+1 |
1 similar comment
+1 |
I've worked on this a ton recently. I wanted to make a What I've deduced is that the This works, up to a point. The native modules in node are not coded in a thread-safe manner. For example, Buffer::HasInstance in node_buffer.cc (in the node repo) checks if an object is a buffer by comparing the object's constructor to one previously set during node's initialization. Since isolates by their nature cannot share JavaScript objects but have the same native memory space, this check will always fail for tagg threads. Therefore a tagg thread can never require the TL:DR I think that if you need to Totally open to input and guidance if anyone has suggestions. |
Wow, great report @jnfeinstein - really sad to see that might not be possible, but good to know! I'm so far from even average at C that my input probably wouldn't be useful, but will be watching from the sidelines! |
Thanks @jnfeinstein for doing that deep research. |
+100 🐶 @jnfeinstein for the awesome response and serious info drop |
By helpers you mean CPU heavy pure javascript snippets? Do I understand correctly that for example, using a module that has a binary part, i.e. I am not entirely sure about the exact workings, but IIRC the tagg-fork
Source: Stack Overflow: Load nodejs module into a web-worker Unfortunately, afaik, this only works with javascript-only modules, not with partially binary modules (i.e. node-expat). |
I believe the Edit: Looked at webworker-threads and it reminded me that Node's built-in functionality (file processing, network, etc) will not work, even if you use onejs. And buffers, per my post above. |
You can use the |
Is this still being pursued somehow? As @jnfeinstein said, onejs/ node packagers do not work with TAGG. |
@abhikco I think this should be possible in nodeJS > 0.11.3, thanks primarily to this commit. I can dig up my old code if you're still interesting in making this work. |
would be amazing! |
That would be awesome! |
How is If I understand correctly, Also, I have difficulty evaluating the pro's ans con's of both, and my choice for the processes at this point is purely functional. |
fork-pool looks pretty straightforward. TAGG is much faster at "IPC" Mostly I like TAGG because JavaScript isn't supposed to be threaded...but
|
Has this been implemented yet? I'd like to use some modules I built inside of a child thread, but can't figure out how to do it. |
yeah, please, "require" keyword in thread |
It is not possible at the moment to require external modules or files from within a thread. I know this is not a bug it is a feature. But it would be much much more helpful if one could use external modules. It is totally obvious to me that this would mean to start up a thread with a bigger context which would also mean a increase in the start-up time for those threads.
The text was updated successfully, but these errors were encountered: