You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdfy/test/test-task-runner.coffee

18 lines
410 B
CoffeeScript

TaskRunner = require "../lib/task-runner"
Promise = require "bluebird"
runner = new TaskRunner()
runner.addTask "testTask", ((task, context) ->
new Promise (resolve, reject) ->
setTimeout ( ->
resolve(task.value * 2)
), (Math.random() * 10)
), maxConcurrent: 10
for i in [0...10000]
runner.do "testTask", value: Math.round(Math.random() * 100)
.then (val) -> console.log "VAL", val
runner.run()