couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/2] git commit: Switch to async readline()
Date Wed, 30 Jan 2013 12:31:48 GMT
Switch to async readline()


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a614678c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a614678c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a614678c

Branch: refs/heads/nodejs_couchdb
Commit: a614678c484f2f88a7baf729133a5bbae34e27b8
Parents: 4a18ddf
Author: Jason Smith (work) <jhs@iriscouch.com>
Authored: Tue Jan 29 12:20:58 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
Committed: Tue Jan 29 12:20:58 2013 +0000

----------------------------------------------------------------------
 share/server/loop.js |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a614678c/share/server/loop.js
----------------------------------------------------------------------
diff --git a/share/server/loop.js b/share/server/loop.js
index fcd016f..76cbbff 100644
--- a/share/server/loop.js
+++ b/share/server/loop.js
@@ -146,7 +146,18 @@ var Loop = function() {
       respond(["error","unnamed_error",e.toSource()]);
     }
   };
-  while (line = readline()) {
+
+  if(readline.async) {
+    readline.async(got_line)
+  } else {
+    while(line = readline())
+      got_line(null, line)
+  }
+
+  function got_line(er, line) {
+    if(er)
+      throw er
+
     cmd = JSON.parse(line);
     State.line_length = line.length;
     try {
@@ -161,6 +172,9 @@ var Loop = function() {
     } catch(e) {
       handleError(e);
     }
+
+    if(readline.async)
+      readline.async(got_line)
   };
 };
 


Mime
View raw message