Skip to content

Commit

Permalink
fix context suspend and resume in notifyAll
Browse files Browse the repository at this point in the history
  • Loading branch information
dstarke committed Jun 1, 2011
1 parent 78c8c53 commit e648f7c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/promise.js
Expand Up @@ -152,7 +152,10 @@ function Deferred(canceller){
throw new Error("This deferred has already been resolved");
}
try{
if(previousContext != context){
if(previousContext !== context){
if(previousContext && previousContext.suspend){
previousContext.suspend();
}
exports.currentContext = context;
if(context && context.resume){
context.resume();
Expand All @@ -165,11 +168,14 @@ function Deferred(canceller){
}
}
finally{
if(previousContext != context){
exports.currentContext = previousContext;
if(context && context.suspend){
if(previousContext !== context){
if(context && context.suspend){
context.suspend();
}
if(previousContext && previousContext.resume){
previousContext.resume();
}
exports.currentContext = previousContext;
}
}
}
Expand Down

0 comments on commit e648f7c

Please sign in to comment.