Skip to content

Commit

Permalink
change callback properties
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Feb 14, 2012
1 parent 9b35388 commit f8dca0e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ class ChainGang extends Events.EventEmitter
# Initializes a ChainGang instance, and a few Worker instances.
#
# options - Options Hash.
# workers - Number of workers to create (default: 3)
# timeout - Optional Number of seconds to wait for the job
# to run.
# timeoutCallback - Optional function to call when timeout is
# triggered.
# emptyCallback - Optional function to call when all jobs are
# complete.
# workers - Number of workers to create (default: 3)
# timeout - Optional Number of seconds to wait for the job to run.
# onTimeout - Optional function to call when timeout is triggered.
# onEmpty - Optional function to call when all jobs are compelete.
#
# Returns ChainGang instance.
constructor: (options) ->
Expand All @@ -22,8 +19,8 @@ class ChainGang extends Events.EventEmitter
@index = {} # name: worker
@active = true
@timeout = options.timeout or 0
@timeoutCb = options.timeoutCallback
@emptyCb = options.emptyCallback
@timeoutCb = options.onTimeout or options.timeoutCallback
@emptyCb = options.onEmpty

# Public: Queues a callback in the ChainGang.
#
Expand Down
2 changes: 1 addition & 1 deletion test/empty_callback_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ chainGang = require '../src/index'

calls = []
onEmpty = false
chain = chainGang.create emptyCallback: -> onEmpty = true
chain = chainGang.create onEmpty: -> onEmpty = true

task = -> assert.fail(onEmpty)
chain.add(task, 'a', -> calls.push(1))
Expand Down
2 changes: 1 addition & 1 deletion test/timer_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ timer = null # timer of the test
chain = chainGang.create(
workers: 1
timeout: 0.1
timeoutCallback: ->
onTimeout: ->
timedOut += 1
clearTimeout timer
)
Expand Down

0 comments on commit f8dca0e

Please sign in to comment.