Comments (6)
I definitely want to address this. I actually ran into some issues as well which led me to begin updating the require()
functionality. I'm actually working on a major update which will include a revamp of the global context for the threads, so that many of the commonly used global objects are available (including __dirname, __filename, and console
). Part of this work includes better require()
support. You can see the work-in-progress on the "experimental" branch.
I will attempt to satisfy all requirements of the algorithm, but can you provide an example of some use-cases that are breaking?
One extra thing to note, at this time I still do not intend to support core Node.js modules or native C/C++ add-ons from within the threads.
from npool.
I wanted to do some work spread across all the CPUs in my box. I can require node modules via require('./node_modules/xxx/index.js')
and this works so long as they don't have dependencies themselves or any relative requires, since the relative requires seem to be resolved relative to the worker.
So, effectively, I have to redo all work developed by most node modules because I can't require them safely in a worker.
If I try, 9 times out of 10 I get a segfault.
from npool.
Accidentally clicked the close button...
I understand the pain and am addressing the path resolution issues in the current updates to require()
from npool.
Thanks. I got the best performance from this library (compared to children), so glad to see improvements.
from npool.
Just an update on this issue. Tonight I updated nPool to version 1.1.0. This included the following changes:
- Support for commonly used Node.js global objects
- require()
- Supports file-based requiring
- Paths that start with './' and '../' is relative to file performing require()
- console.log
- __filename
- __dirname
- require()
This should help alleviate some of the pain with requiring files within worker modules. Think of this as phase one for emulating the require() functionality. My next focus is to completely replicate it (with the exception of native modules of course). This will be a minor version bump, most likely 1.1.1.
from npool.
I no longer require this functionality. Closing the issue, fill free to reopen if you plan on working on it.
from npool.
Related Issues (9)
- webworker polyfill HOT 1
- Unable to install on Windows - error C2440: 'function' : cannot convert from 'THREAD_FUNC (__cdecl *)(void *)' to 'unsigned int (__stdcall *)(void *)' HOT 7
- require an installed node module HOT 1
- Update to nan v2.0.4 HOT 2
- segfault if thread function's last statement is console.log
- Node >= 0.11.x support? HOT 4
- Code load support HOT 2
- Event Emitter interface for threads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npool.