import { workers } from 'moroutine'; import { busy } from './load-balancing.ts'; // Overlapping tasks on a lazy pool: if completing the short task unref'd // the pool while the long one was still in flight, the process would exit // (code 13) before LONG completes and this would never print. const run = workers(2, { refMode: 'lazy' }); const short = run(busy(20)); const long = run(busy(120)); await short; const r = await long; console.log('DONE ' + r);