How to use the fibers/future.task function in fibers

To help you get started, we’ve selected a few fibers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackhat / selenium-sync / src / core / Browser.js View on Github external
this.__driver  = options.driver;
    }else{
        if(options.driverType === 'chrome'){
            this.__driver = new ChromeDriver();
        }
    }
    this.__windows = [];
    this.__quitted = false;

    // First update should be run in the current fiber "thread" in order
    // to setup the first window before any other call.
    this.update();

    // The update loop should run in another fiber "thread" to don't
    // block the current one. If not it will not go beyond this step.
    Future.task(function(){
        while(true && !this.__quitted){
            utils.sleep(100).wait();
            this.update();
        }
    }.bind(this)).detach();
}
github hackhat / cucumberry / src / core / plugins / makeFiber.js View on Github external
var fiberFn = function(){
            var args = Array.prototype.slice.call(arguments);
            // Extract and remove the cb from the arguments.
            var cb   = args.pop();
            Future.task(function(){
                fn.apply(this, args);
                // Because is running with fibers is sync. Therefore
                // we can call cb() after the fn ends in sync.
                cb();
            }.bind(this)).detach();
        }
        this.__makeFiber_origGiven(regexp, fiberFn);