Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

at e2cebd539403475e2f4e79d55ca1a84a0ce3510d 14 lines 428 B view raw
1import { workers } from 'moroutine'; 2import { busy } from './load-balancing.ts'; 3 4// Dispatches CPU-bound tasks on a dedicated worker, then on a pool. 5// The process should complete and print DONE; if pool workers 6// are unref'd the event loop may exit early (exit code 13). 7 8await busy(10); 9 10{ 11 using run = workers(2); 12 const results = await run([busy(50), busy(50), busy(50)]); 13 console.log('DONE ' + results.join(',')); 14}