Skip to content
/ co-thread Public

Run a generator function in parallel N times for light-weight threading

Notifications You must be signed in to change notification settings

tj/co-thread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-thread

Run a generator function in parallel N times.

Installation

$ npm install co-thread

Example

Send requests in batches of 20:

var thread = require('co-thread');
var get = require('co-request');
var co = require('co');

co(function *(){
  var times = 10;

  while (times--) {
    yield thread(function *(){
      var a = yield get('http://google.com');
      console.log(a.statusCode);

      var b = yield get('http://yahoo.com');
      console.log(b.statusCode);
    }, 20);
  }
})();

License

MIT

About

Run a generator function in parallel N times for light-weight threading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages