uhwait
A simple async/await gadget that adds seamless message passing to JavaScript.
npm install uhwait
Requires node.js >= v8.9.0. Previous versions of node have an incomplete version of the async_hooks
implementation that will not work.
Usage
uhwait is not intended to be used in a practical way, it's was written primarily to educate developers about message passing, actors, and concurrency.
uhwait provides spawn
, self
, and receive
semantics, that when used with async/await
(kind of) emulate the behaviour of erlang.
On top of those primitives, the pid
object returned by spawn provides pid.send(...args)
to send a message to the process, and pid.join()
to wait until a process exits.
An actor's 'process' context is fully managed through subsequent async continuations, regardless of nesting. join
will properly wait until there are no more continuations remaining. See examples/helloworld.js
for details.
const self receive spawn = ; { const msg = await ; console; ;} { await pid; console;} const hello = ;;hello;hello;
See examples/
for more.