Permalink
Browse files

2.1.6

Allow the current asyncblock's flow to be gotten from a function called from the current fiber.
  • Loading branch information...
scriby committed Oct 4, 2012
1 parent 86adc82 commit c01d14c88677fa88a04e1b9aeae97aa4446c8cc3
Showing with 59 additions and 2 deletions.
  1. +28 −0 changelog
  2. +11 −1 lib/asyncblock.js
  3. +1 −1 package.json
  4. +19 −0 tests/functionality.js
View
@@ -1,3 +1,31 @@
+2.1.6
+
+* Allow the current asyncblock's flow to be gotten from a function called from the current fiber.
+
+2.1.5
+
+* Allow asyncblock transform compilation to be kicked off independently. This allows a build process or otherwise to run the transformations beforehand.
+
+2.1.4
+
+* Fix an instance of errors getting swallowed within nested asyncblocks.
+
+2.1.3
+
+* Allow 2nd arg to be specified to an asyncblock, which acts as the return handler.
+
+2.1.2
+
+* Fix an issue with deferred variables not getting handled correctly if assigned to an object property
+
+2.1.1
+
+* Fix issue with asyncblock not working with Coffeescript
+
+2.1.0
+
+* Update to fibers v0.6.8 for node v0.8 support.
+
2.0.9
* x().sync() optimization - Reuse the fiber from the outer asyncblock in the inner asyncblock. Lower overhead and same behavior.
View
@@ -109,7 +109,7 @@ var asyncblock = function(fn, done, options) {
};
module.exports = function(fn, done, options){
- //Capture stack trace by defaultrequire('./lib/transform.js');
+ //Capture stack trace by default
var err = new Error();
//Currently not capturing stack trace as it's about 60% slower than just making the error (and just takes 1 frame off stack trace)
//Error.captureStackTrace(err, module.exports);
@@ -147,3 +147,13 @@ module.exports.fullstack = module.exports;
module.exports.nostack = function(fn, done){
asyncblock(fn, done);
};
+
+module.exports.getCurrentFlow = function(){
+ var currFiber = Fiber.current;
+ if(currFiber){
+ var currFlow = currFiber._asyncblock_flow;
+ currFiber = null;
+
+ return currFlow;
+ }
+};
View
@@ -1,6 +1,6 @@
{
"name": "asyncblock",
- "version": "2.1.5",
+ "version": "2.1.6",
"description": "A simple and powerful abstraction of node-fibers",
"keywords": [
"fiber", "fibers", "coroutine", "stop", "go", "green", "red" ],
View
@@ -1048,6 +1048,25 @@ suite.addBatch({
'The results are as expected': function(err, result){
assert.equal(err.message, 'Error');
}
+ },
+
+ 'When using asyncblock.currentFlow': {
+ topic: function(){
+ var testCurrent = function(){
+ var flow = asyncblock.getCurrentFlow();
+
+ echo('test', flow.add());
+ return flow.wait();
+ };
+
+ asyncblock(function(){
+ return testCurrent();
+ }, this.callback);
+ },
+
+ 'Ok': function(result){
+ assert.equal(result, 'test');
+ }
}
});

0 comments on commit c01d14c

Please sign in to comment.