about summary refs log tree commit diff stats
path: root/075channel.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-26 13:27:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-26 13:27:57 -0700
commit029a3bdf53b523eded91a30177affdcace3bb2a1 (patch)
tree8984ca1073ee20950d74d091eca4fb07e04f321f /075channel.mu
parentad2604e893edbb3cde3d5e14cf4418acd3ef7d65 (diff)
downloadmu-029a3bdf53b523eded91a30177affdcace3bb2a1.tar.gz
3258
In the process of debugging the last couple of commits (though I no
longer remember exactly how) I noticed that 'wait-for-routine' only
waits until the target routine stops running for any reason, including
when it blocks on something. That's not the synchronization primitive we
want in production code, even if it's necessary for some scenarios like
'buffer-lines-blocks-until-newline'. So we rename the old 'wait-for-routine'
primitive to 'wait-for-routine-to-block', and create a new version of
'wait-for-routine' that say callers of 'start-writing' can safely use,
because it waits until a target routine actually completes (either
successfully or not).
Diffstat (limited to '075channel.mu')
-rw-r--r--075channel.mu8
1 files changed, 4 insertions, 4 deletions
diff --git a/075channel.mu b/075channel.mu
index 72d039a9..f299836a 100644
--- a/075channel.mu
+++ b/075channel.mu
@@ -419,28 +419,28 @@ scenario buffer-lines-blocks-until-newline [
 F buffer-lines-blocks-until-newline: channel should be empty after init]
     # buffer stdin into buffered-stdin, try to read from buffered-stdin
     buffer-routine:number <- start-running buffer-lines, source, buffered-stdin
-    wait-for-routine buffer-routine
+    wait-for-routine-to-block buffer-routine
     empty? <- channel-empty? buffered-chan
     assert empty?:boolean, [ 
 F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up]
     # write 'a'
     sink <- write sink, 97/a
     restart buffer-routine
-    wait-for-routine buffer-routine
+    wait-for-routine-to-block buffer-routine
     empty? <- channel-empty? buffered-chan
     assert empty?:boolean, [ 
 F buffer-lines-blocks-until-newline: channel should be empty after writing 'a']
     # write 'b'
     sink <- write sink, 98/b
     restart buffer-routine
-    wait-for-routine buffer-routine
+    wait-for-routine-to-block buffer-routine
     empty? <- channel-empty? buffered-chan
     assert empty?:boolean, [ 
 F buffer-lines-blocks-until-newline: channel should be empty after writing 'b']
     # write newline
     sink <- write sink, 10/newline
     restart buffer-routine
-    wait-for-routine buffer-routine
+    wait-for-routine-to-block buffer-routine
     empty? <- channel-empty? buffered-chan
     data-emitted?:boolean <- not empty?
     assert data-emitted?, [