I'm pleased to announce the release of asyncblock 2.0.0, a flow
control library built on fibers.

What's a fiber?

Fibers are special javascript threads that can be paused without
blocking the event loop. When async tasks complete, a paused fiber can
resume in its original state with the result of the async task.

It's important to note that fibers do not increase concurrency in V8
-- there is still a single thread executing at once, and context
switching works the same as vanilla V8.

Fibers themselves are maintained at https://github.com/laverdet/node-fibers.

Sounds great! Why do I need asyncblock?

Because fibers is too low level to use directly for most use cases.
asyncblock manages your most demanding series and parallel control
flows with ease. It's a library for people and teams that just want to
get their program logic expressed in a simple, straightforward, and
easy to modify and maintain fashion. The more complicated your
problem, the more asyncblock will help.

But wait, there's more! asyncblock helps solve some other common
problems. It will automatically stitch together call stacks before
async calls -- so you can get the whole picture when debugging. It
also provides an easy way to handle errors, whether they're thrown
exceptions or errors returned from callbacks.

Wonderful. How do I get it?

Check out the project page at https://github.com/scriby/asyncblock.

What's new in version 2?

asyncblock 2.0.0 provides new on-the-fly source transformation to
provide even more concise and straightforward ways to write node code.

You can chain a .sync(), .defer(), or .future() on to the end of any
async function call. Sync pauses the fiber until the async task
finishes. Defer pauses the fiber on first access to the assigned
variable (just-in-time yielding). Future returns an object exposing
a .result property which will yield when accessed the first time.

Imagine if you could write code like this:

asyncblock(function(flow) {
    //Start two parallel file reads
    var contents1 = fs.readFile(path1, 'utf8').defer();
    var contents2 = fs.readFile(path2, 'utf8').defer();

    //Print the concatenation of the results when both reads are
finished
    console.log(contents1 + contents2);

    //One-liner syntax for waiting on a single task
    var contents = fs.readFile(path, 'utf8').sync();
});

Now you can! The debugger and stack traces still work because line
numbers are maintained during the transformation.

Aren't there some other similar projects?

Yeah, and you might like the way they approach the same problem.

https://github.com/0ctave/node-sync
https://github.com/Sage/streamlinejs
https://github.com/maxtaco/tamejs

Or, if you're using a fibers-based framework like 
https://github.com/maccman/ace,
asyncblock or node-sync would be a great addition to your project.

Comments, compliments, and criticism welcome,

Scriby

-- 
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

Reply via email to