News for hackers. Stuff that matters.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi... by drinchev on Wednesday May 24, 2017 @03:12AM (#14408099)
Reminds me of `node-fibers`[1]

    var Fiber = require('fibers');

    function sleep(ms) {
        var fiber = Fiber.current;
        setTimeout(function() {
            fiber.run();
        }, ms);
        Fiber.yield();
    }

    Fiber(function() {
        console.log('wait... ' + new Date);
        sleep(1000);
        console.log('ok... ' + new Date);
    }).run();
    console.log('back in main');
It is used heavily in meteor[2]

1: https://github.com/laverdet/node-fibers 2: https://github.com/meteor/meteor

There are no comments on this comment yet.