Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DonutEspresso committed Jan 24, 2017
1 parent c26b65b commit ee5dfe6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ If your function returns an error to the callback, this event will be emitted.
The subscribed function will receive an error as it's only parameter.

### handler.on('stop', function() {...})
When the `stop()` method is called, this event is emitted when when either the
When the `stop()` method is called, this event is emitted when either the
current invocation is successfully completed, or when the next scheduled
invocation is successfully cancelled. If the current invocation is "stuck" in
the sense that the callback never returns, the stop event will never fire.

### handler.on('timeout', function() {...})
If a `timeout` value is specified, this event will be fired when any given
invocation of the function exceeds the specified value.
invocation of the function exceeds the specified value. However, if your user
supplied function is synchronous, and never gives up the event loop, it is
possible that this event may never get fired.


## Contributing
Expand Down
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ Reissue.prototype._execute = function _execute() {
self._startTime = Date.now();
// set flag so we know we're currently in user supplied func
self._inUserFunc = true;
// execute their func
self._func.apply(self._funcContext, self._funcArgs);
// execute their func on a setImmediate, such that we can schedule the
// timeout first. to be clear though, user func could be sync and our
// timeout may never fire.
setImmediate(function _executeImmediately() {
self._func.apply(self._funcContext, self._funcArgs);
});

// if timeout option is specified, schedule one here. basically, we
// execute the next invocation immediately above, then schedule a
Expand Down

0 comments on commit ee5dfe6

Please sign in to comment.