Skip to content

Commit

Permalink
Allow up to 16383 callbacks on a Deferred.
Browse files Browse the repository at this point in the history
Change-Id: I9f9a7fb5110f693db6813c0b8a62f0d03b896a1e
  • Loading branch information
tsuna committed Apr 8, 2012
1 parent 174586d commit d67b649
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NEWS
Expand Up @@ -5,6 +5,11 @@ StumbleUpon's Async Library - User visible changes.
Noteworthy changes:
- Optimization: the internal state of a Deferred is now captured
in a plain `int' instead of using an enum.
- The maximum number of callbacks allowed on a Deferred has been
significantly increased, from 128 to 16383, to allow for some
use cases where a large number of operations are waiting on a
single asynchronous operation to complete. This implementation
cannot support more than this many callbacks without refactoring.


* Version 1.1.0 (2011-09-27) [cf62d8d]
Expand Down
7 changes: 5 additions & 2 deletions src/Deferred.java
Expand Up @@ -439,11 +439,14 @@ public final class Deferred<T> {

/**
* Maximum length of the callback chain we allow.
* Set this to some aggressive limit to quickly detect problems in code
* Set this to some arbitrary limit to quickly detect problems in code
* that creates potentially infinite chains. I can't imagine a practical
* case that would require a chain with more callbacks than this.
*/
private static final short MAX_CALLBACK_CHAIN_LENGTH = 128;
private static final short MAX_CALLBACK_CHAIN_LENGTH = Short.MAX_VALUE >> 1;
// NOTE: The current implementation cannot support more than this many
// callbacks because indexes used to access the `callbacks' array are
// of type `short' to save memory.

/**
* How many entries do we create in the callback+errback chain by default.
Expand Down

0 comments on commit d67b649

Please sign in to comment.