Permalink
Browse files

closes #40

  • Loading branch information...
1 parent 3af1a9d commit 294b83525a22ff2913db36252289003b5e21dfc6 @olegp committed May 19, 2012
Showing with 22 additions and 21 deletions.
  1. +1 −1 README.md
  2. +3 −3 lib/fs-base.js
  3. +3 −2 lib/httpclient.js
  4. +5 −5 lib/io.js
  5. +4 −4 lib/socket.js
  6. +2 −2 lib/subprocess.js
  7. +3 −3 lib/system.js
  8. +1 −1 package.json
View
@@ -30,7 +30,7 @@ The following modules are included:
If you don't already have them, [install Node version 0.5.2 or later](https://github.com/joyent/node/wiki/Installation) (for Node 0.4.X check out the v0.4 branch of Common Node) and [Node Package Manager](http://npmjs.org). It's also highly recommended that you have your $NODE_PATH variable [set correctly](https://github.com/olegp/common-node/issues/20).
-Install `common-node` as a global package (use `sudo` if you're on Ubuntu):
+Install `common-node` as a global package (use `sudo` if you're on Ubuntu or Mac):
npm -g install common-node
View
@@ -3,7 +3,7 @@
* Filesystem/A](http://wiki.commonjs.org/wiki/Filesystem/A).
* @name fs
*/
-require('fibers');
+var Fiber = require('fibers');
var nodePath = require('path');
var fs = require('fs');
@@ -213,7 +213,7 @@ function sync(method) {
fiber.run(err || result);
});
method.apply(null, args);
- var result = yield();
+ var result = Fiber.yield();
if(result instanceof Error)
throw new Error(result.message);
return result;
@@ -432,7 +432,7 @@ var exists = exports.exists = function(path) {
nodePath.exists(path, function(e) {
fiber.run(e);
});
- return yield();
+ return Fiber.yield();
};
/**
View
@@ -2,7 +2,8 @@
* @fileoverview HTTP Client as defined in [CommonJS HTTP
* Client/A](http://wiki.commonjs.org/wiki/HTTP_Client/A).
*/
-require('fibers');
+var Fiber = require('fibers');
+
var protocols = {
http: require('http'),
https: require('https')
@@ -204,7 +205,7 @@ HttpClient.prototype.read = function() {
});
req.end();
- var result = yield();
+ var result = Fiber.yield();
if(result instanceof Error)
throw new Error(result.message);
return {
View
@@ -3,7 +3,7 @@
* IO/A](http://wiki.commonjs.org/wiki/IO/A) as well as a ByteArray based in
* memory MemoryStream.
*/
-require('fibers');
+var Fiber = require('fibers');
var binary = require('./binary');
var Binary = binary.Binary, ByteArray = binary.ByteArray, ByteString = binary.ByteString;
@@ -128,7 +128,7 @@ Stream.prototype.forEach = function(callback, thisObject) {
}
if(!this.closed()) {
var listeners = attach(this.stream), data;
- while(data = yield()) {
+ while(data = Fiber.yield()) {
if(!(data instanceof Buffer))
break;
callback.call(thisObject, new ByteArray(data));
@@ -170,7 +170,7 @@ Stream.prototype.read = function(n) {
// don't attach listeners unless we need to
if(!this.closed()) {
var listeners = attach(this.stream), data;
- while((data = yield()) && r < n) {
+ while((data = Fiber.yield()) && r < n) {
if(!(data instanceof Buffer))
break;
blocks.push(data);
@@ -214,7 +214,7 @@ Stream.prototype.read = function(n) {
}
var listeners = attach(this.stream);
- var data = yield();
+ var data = Fiber.yield();
detach(this.stream, listeners);
if(!data) {
this.close();
@@ -338,7 +338,7 @@ Stream.prototype.flush = function() {
fiber.run();
};
this.stream.on('drain', ondrain);
- yield();
+ Fiber.yield();
this.stream.removeListener('drain', ondrain);
};
View
@@ -2,7 +2,7 @@
* @fileoverview Socket class as defined in the [CommonJS
* Sockets/A](http://wiki.commonjs.org/wiki/Sockets/A) proposal.
*/
-
+var Fiber = require('fibers');
var net = require('net');
var io = require('./io');
@@ -54,7 +54,7 @@ Socket.prototype.connect = function(host, port, timeout) {
client.on('error', function(error) {
fiber.run(error);
});
- var result = yield();
+ var result = Fiber.yield();
if(result instanceof Error) {
throw new Error(result.message);
}
@@ -83,7 +83,7 @@ Socket.prototype.bind = function(host, port) {
fiber.run();
});
// TODO add a listener to queue up connections until accept is called
- var result = yield();
+ var result = Fiber.yield();
if(result instanceof Error) {
throw new Error(result.message);
}
@@ -102,7 +102,7 @@ Socket.prototype.accept = function() {
fiber.run(socket);
};
this.server.on('connection', onconnection);
- var result = yield();
+ var result = Fiber.yield();
this.server.removeListener('connection', onconnection);
return new Socket(result);
};
View
@@ -2,7 +2,7 @@
* @fileOverview A module for spawning processes, connecting to their
* input/output/errput and returning their response codes.
*/
-
+var Fiber = require('fibers');
var childProcess = require('child_process');
var io = require('./io');
@@ -124,7 +124,7 @@ var createProcess = exports.createProcess = function(args) {
child.on('exit', function(code) {
fiber.run(code);
});
- return yield();
+ return Fiber.yield();
},
/**
View
@@ -5,7 +5,7 @@
* the current thread, spawning a new thread and spawning
* processes are provided.
*/
-require('fibers');
+var Fiber = require('fibers');
var io = require('./io');
var Stream = io.Stream, TextStream = io.TextStream;
@@ -92,7 +92,7 @@ exports.parallel = function(fibers) {
});
var result = [];
while(index --) {
- var r = yield();
+ var r = Fiber.yield();
result[r[0]] = r[1];
}
return result;
@@ -110,7 +110,7 @@ exports.sleep = function(milliseconds) {
setTimeout(function() {
fiber.run();
}, milliseconds);
- yield();
+ Fiber.yield();
};
global.getResource = function(name) {
View
@@ -16,7 +16,7 @@
"main": "./lib/all.js",
"bin": { "common-node": "./bin/common-node" },
"engines": { "node": ">= 0.5.2" },
- "dependencies" : { "fibers": ">= 0.6.1" },
+ "dependencies" : { "fibers": ">= 0.6.7" },
"preferGlobal": true,
"licenses": [ { "type": "MIT" } ]
}

0 comments on commit 294b835

Please sign in to comment.