Hi, I'm the author of a fibers abstraction called asyncblock.
(https://github.com/scriby/asyncblock).
I read over the details of harmony generators, and I can tell that
existing fibers based solutions will not be able to transparently
switch over to generators. There are two main problems:
1. The function needs to have an asterisk after it (not a huge deal)
2. The existing syntax can't work directly as you must use yield
directly from the generator function. It's not like fibers where we
can yield further up the call stack of a function running in a fiber
So, I think the only reasonable solutions for long term planning and
avoiding CPS style code involve syntax transformation. Asyncblock has
beta support for syntax rewriting, and I plan on basing it off
generators when they become available in v8.
The syntax rewriting lets you write code like
asyncblock(function(flow){
//defer makes the first access to file1 yield until it's ready
var file1 = fs.readFile(path, 'utf8').defer();
//sync makes the fiber yield until the result is obtained
var file2 = fs.readFile(path, 'utf8').sync();
console.log(file1 + file2);
});
Right now that code compiles to use fibers. There's plenty of good CPS
transforms out there of you want to avoid fibers for now, or of you
need windows or browser support (be careful about losing line numbers
though).
Good luck making your decision,
Chris
On Feb 10, 1:17 pm, "john.tiger" <[email protected]> wrote:
> for a project we do not want lots of nested callbacks so
> 1) where is node in regards to using harmony generators ?
> 2) is node-fibers a fork or add on module ?
> 3) if we use node-fibers and then later generators becomes "standard" -
> would there be much rewriting required ?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en