3. //node.js
var data;
//传统代码 fs.readFile('file.txt',
var file = open('file.txt'); function(err, data){
var data = file.read(); data = data;
doSomething(data); }
);
doSomething(data);
10. 更多 Flow control / Async goodies
https://github.com/joyent/node/wiki/modules#async-flow
11. Coroutine( 协程 )?
Cooperative threading of any sort is a bad idea.
--ry@jsconf2010
●
讨论:
●
http://shiningray.cn/node-js-coroutine.html
●
http://news.ycombinator.com/item?id=1549168
24. Web Worker
● 耗 CPU 的操作放到 worker 中,
不阻塞主进程
● 多 CPU 支持
● 目前 Node.js 还不支持 Web Worker
●
In future versions, Node will be able to fork new
processes (using the Web Workers API ) which
fits well into the current design. – nodejs.org
● https://github.com/pgriess/node-webworker