bchociej / bobbin Goto Github PK
View Code? Open in Web Editor NEWeasily spool up thread-like worker processes in node with bobbin
License: Other
easily spool up thread-like worker processes in node with bobbin
License: Other
distinguish between 'kill when work is done' and 'kill now'.
this will require some thought. how to stop these once started, for example.
repetitive:
pool.run (cb) ->
i = 0
setInterval( -> cb(i++) , 1000)
long-running:
pool.run -> doWorkForever()
so it can be managed/killed/whatever
run, kill, etc are really applicable to both workers and the pool as a whole. formalize this relationship in code.
why not let the end user, e.g., grab some worker and feed it work, if that's what they wish to do. or kill it. or whatever! or push workers onto a pool. who cares?
blocked by #18
cluster.fork()
implies synchronous IPC for passing messages. perhaps using child_process
and pipes would speed things up in certain cases.
basically I want to plug caolan/async into this (or just mimic functionality as needed) to make data processing magically SMP-enabled:
async_bobbin.each(collection, function(item, callback) {
// this iterator runs on the workers!
callback(doSomething(item));
});
i think all or almost all of caolan/async could be adapted onto bobbin. (imagine async.auto
applied to workers!) some kind of bridge/adapter/facade shouldn't be hard to make.
threads_a_gogo has done a lot of heavy lifting already to get fast threads in node. the work-sending paradigm is similar. become a nice API on top of a library such as that one? or, implement native threads ourselves?
note to self: libuv threads aren't scary at all https://nikhilm.github.io/uvbook/threads.html#core-thread-operations , neither are native addons in general http://nodejs.org/api/addons.html#addons_wrapping_c_objects
can lazy.js or its ilk be wrapped? seems impossible structurally. maybe the concept of sequences can be ported. it'd be cool to get the lazy evaluation mapped onto workers.
e.g.
pool.run(function() { return something; })
given e.g. lambdaws, it'd be swell to support other "compute backends" e.g. lambdaws, other machines on the network, etc
currently the poor user has to inject the full path into pool.run
so that the worker's require
can find it
round robin isn't the only option of course. maybe keep a count of active tasks on each worker and prioritize accordingly? maybe expose explicit options to direct work at certain workers. maybe allow submission of task batches; could be more efficient.
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.