Permalink
Browse files

fix context suspend and resume in notifyAll

  • Loading branch information...
1 parent 78c8c53 commit aedcac1ae6c41c52de1f9cd6f74913a8402565b5 @dstarke dstarke committed with David Starke Jun 1, 2011
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/promise.js
View
@@ -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();
@@ -165,11 +168,14 @@ function Deferred(canceller){
}
}
finally{
- if(previousContext != context){
- exports.currentContext = previousContext;
- if(context && context.suspend){
- context.suspend();
+ if(previousContext !== context){
+ if(context && context.suspend){
+ context.suspend();
+ }
+ if(previousContext && previousContext.resume){
+ previousContext.resume();
}
+ exports.currentContext = previousContext;
}
}
}

0 comments on commit aedcac1

Please sign in to comment.