laverdet/node-fibers — Issue #42: yielding within nextTick
Author: scriby
Created: 2011-12-23 16:10:57+00:00
State: open

Hi,

I'm working through an issue with asyncblock, and I was wondering if you could help me figure something out. The basic case I want looks like this:

```javascript
var asyncTask = function(callback) {
process.nextTick(function() {
callback();
});
};

var fiber = Fiber(function(){
process.nextTick(function(){
asyncTask(function() {
fiber.run();
});

var asyncTaskResult = Fiber.yield();
});
});
```

The problem I'm running into with the above example is that Fiber.yield doesn't work -- "yield() called with no fiber running". I tried storing Fiber.current in a variable, and manually setting Fiber.current before calling yield, but that doesn't seem to work either.

I'm guessing that even if the Fiber.yield call worked, the fiber.run call wouldn't for a similar reason. I read your response to #24, which I think provides a workaround for that issue. I can try it out if I can get past the yield issue.

Thanks,

Chris