diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 13:00:39 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 13:00:39 -0700 |
commit | a0331a9b0eab63a000dcd022fe605d124c573b8d (patch) | |
tree | 5c7403d16fd8c9d31ead65495eae84edf9cfc2e4 /075channel.mu | |
parent | 760f683f2755038a1b0c16522f5001b889096aa5 (diff) | |
download | mu-a0331a9b0eab63a000dcd022fe605d124c573b8d.tar.gz |
3390
Diffstat (limited to '075channel.mu')
-rw-r--r-- | 075channel.mu | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/075channel.mu b/075channel.mu index ed3dee3b..6aae8b87 100644 --- a/075channel.mu +++ b/075channel.mu @@ -30,7 +30,7 @@ container channel:_elem [ # A circular buffer contains values from index first-full up to (but not # including) index first-empty. The reader always modifies it at first-full, # while the writer always modifies it at first-empty. - data:&:array:_elem + data:&:@:_elem ] # Since channels have two ends, and since it's an error to use either end from @@ -51,7 +51,7 @@ def new-channel capacity:num -> in:&:source:_elem, out:&:sink:_elem [ *result <- put *result, first-full:offset, 0 *result <- put *result, first-free:offset, 0 capacity <- add capacity, 1 # unused slot for 'full?' below - data:&:array:_elem <- new _elem:type, capacity + data:&:@:_elem <- new _elem:type, capacity *result <- put *result, data:offset, data in <- new {(source _elem): type} *in <- put *in, chan:offset, result @@ -85,7 +85,7 @@ def write out:&:sink:_elem, val:_elem -> out:&:sink:_elem [ current-routine-is-unblocked #? $print [performing write], 10/newline # store a deep copy of val - circular-buffer:&:array:_elem <- get *chan, data:offset + circular-buffer:&:@:_elem <- get *chan, data:offset free:num <- get *chan, first-free:offset val-copy:_elem <- deep-copy val # on this instruction rests all Mu's concurrency-safety *circular-buffer <- put-index *circular-buffer, free, val-copy @@ -131,7 +131,7 @@ def read in:&:source:_elem -> result:_elem, eof?:bool, in:&:source:_elem [ current-routine-is-unblocked # pull result off full:num <- get *chan, first-full:offset - circular-buffer:&:array:_elem <- get *chan, data:offset + circular-buffer:&:@:_elem <- get *chan, data:offset result <- index *circular-buffer, full # clear the slot empty:&:_elem <- new _elem:type @@ -371,7 +371,7 @@ def channel-full? chan:&:channel:_elem -> result:bool [ def capacity chan:&:channel:_elem -> result:num [ local-scope load-ingredients - q:&:array:_elem <- get *chan, data:offset + q:&:@:_elem <- get *chan, data:offset result <- length *q ] |