inh3 / npool Goto Github PK
View Code? Open in Web Editor NEWA cross-platform thread pool add-on for Node.js and io.js.
License: Other
A cross-platform thread pool add-on for Node.js and io.js.
License: Other
I get the following error when trying to install on Windows 8. Any suggestions appreciated!
E:\myproject>npm install npool
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/npool
npm http 304 https://registry.npmjs.org/npool
> [email protected] install E:\myproject\node_modules\npool
> node-gyp rebuild
E:\myproject\node_modules\npool>node "E:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
thread_pool.c
task_queue.c
synchronize.c
..\threadpool\synchronize.c(65): error C2440: 'function' : cannot convert from 'THREAD_FUNC (__cdecl *)(void *)' to 'unsigned int (__stdcall *)(void *)'
[E:\myproject\node_modules\npool\build\threadpool.vcxproj]
..\threadpool\synchronize.c(65): warning C4024: '_beginthreadex' : different types for formal and actual parameter 3 [E:\myproject\node_modules\npool\build\threadpool.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (E:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "E:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\myproject\node_modules\npool
gyp ERR! node -v v0.10.21
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
E:\myproject>
Apparently it's not possible to load an installed module from within a work unit.
Here below an example, just to give an idea:
main file:
var nPool = require('npool');
nPool.loadFile(1, __dirname + '/test.js');
nPool.createThreadPool(20);
var unitOfWork = {
workId: uniqID(),
fileKey: 1,
workFunction: "run",
workParam: {},
callbackFunction: callbackFunction,
callbackContext: funcion () {}
};
// queue the unit of work
nPool.queueWork(unitOfWork);
test.js
var fs = require('fs');
This is the error generated:
{ message: 'Uncaught Error: Require::RequireFunction - File Name is invalid: fs',
resourceName: 'test.js',
lineNum: 1,
sourceLine: 'var fs = require(\'fs\'),',
stackTrace: 'Error: Require::RequireFunction - File Name is invalid: fs\n at test.js:1:10' }
Is there any known workaround until the problem will be fixed?
Thank you
dunno if this makes full sense but I think it might be interesting to polyfill the web worker API, that way I could use this with https://github.com/substack/webworkify
I understand that you have to emulate require to work around it only being available on the main thread, but you you implement the http://nodejs.org/docs/v0.4.8/api/all.html#all_Together... algorithm so one can require dependencies like normal? This would also allow us to require dependencies that require other dependencies without having everything break.
Like in gogo lib, but with type support (not only toString() all arguments).
This currently breaks support for iojs v3.0.0 until complete.
Example thread function file:
module.exports = function() { this.work_method = function( data ) { console.log("WORKMETHOD"); } };
When executed via nPool.queueWork(...); it segfaults.
I'm sure you have a lot on your plate and that it's not necessary a quick change, but I was wondering if there was any plans for supporting node > 0.10.x ?
I'd like to help if I can at some point, but I have to brush up on my C/C++ first :)
Is it possiable to load code not only from file but
Thanks for your work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.