mercurial/HGCommandServer.st
branchhg-command-server-support
changeset 233 d9a8bb2aaa0b
parent 232 718711b15cea
child 235 3d8ef499d7d9
--- a/mercurial/HGCommandServer.st	Sun Mar 03 19:43:56 2013 +0000
+++ b/mercurial/HGCommandServer.st	Sun Mar 03 19:59:26 2013 +0000
@@ -97,7 +97,7 @@
 
     command := anHGCommand.
     anHGCommand initialize.
-    blocker := Semaphore new.
+    blocker := command blocker.
 
     self runcommand: command.
 
@@ -127,7 +127,7 @@
     ^anHGCommand status: status result: anHGCommand result
 
     "Created: / 24-02-2013 / 15:10:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-03-2013 / 19:41:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-03-2013 / 19:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGCommandServer methodsFor:'initialization'!
@@ -296,16 +296,16 @@
     len := input nextUnsignedLongNet.
     data := input next: len.
     channel update: data encoder: encoder.
-"/    command notNil ifTrue:[
-"/        channel := channel_o ifTrue:[
-"/            command spawnOutputReaderOn: channel_o
-"/        ] ifFalse:[channel := channel_e ifTrue:[
-"/            command spawnErrorReaderOn: channel_e
-"/        ]].
-"/    ].
+    command notNil ifTrue:[
+        channel := channel_o ifTrue:[
+            command spawnOutputReaderOn: channel_o
+        ] ifFalse:[channel := channel_e ifTrue:[
+            command spawnErrorReaderOn: channel_e
+        ]].
+    ].
 
     "Created: / 24-02-2013 / 14:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-03-2013 / 18:20:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-03-2013 / 19:44:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGCommandServer methodsFor:'start & stop'!
@@ -545,15 +545,12 @@
 !HGCommandServer::InputChannel methodsFor:'testing'!
 
 atEnd
-    | atEnd |
-
-    lock critical:[
-        atEnd := closed and:[super atEnd].
+    ^self readWaitWithTimeoutMs: nil do:[
+        closed and:[((position-ZeroPosition+1) > readLimit)]
     ].
-    ^atEnd
 
     "Created: / 03-03-2013 / 15:36:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-03-2013 / 17:40:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-03-2013 / 19:57:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGCommandServer::InputChannel methodsFor:'updating'!
@@ -605,9 +602,10 @@
 readWaitWithTimeoutMs:millis do: block
     [
         lock critical:[
-            ((position-ZeroPosition+1) <= readLimit) ifTrue:[
+            (closed or:[((position-ZeroPosition+1) <= readLimit)]) ifTrue:[
                 ^block value
             ].
+
         ].
         self trace: 'waiting for data'.
         rlock waitWithTimeoutMs:millis.