diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 01:01:07 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-19 01:01:07 -0700 |
commit | 13cd9363dd87b9aee9de403bcf36443a73eaa42b (patch) | |
tree | 1d4860ec23a8fde6b67b9c148b44629fdd218bf0 | |
parent | db50f43a79f91b2f984ddae0c05100dafb9fde05 (diff) | |
download | mu-13cd9363dd87b9aee9de403bcf36443a73eaa42b.tar.gz |
2793 - more fixes to make channels generic
Finally..
-rw-r--r-- | 072channel.mu | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/072channel.mu b/072channel.mu index 95641fb4..55ec5ae2 100644 --- a/072channel.mu +++ b/072channel.mu @@ -43,11 +43,11 @@ def new-channel capacity:number -> result:address:shared:channel:_elem [ *free <- copy 0 # result.data = new location[ingredient+1] capacity <- add capacity, 1 # unused slot for 'full?' below - dest:address:address:shared:array:character <- get-address *result, data:offset - *dest <- new character:type, capacity + dest:address:address:shared:array:_elem <- get-address *result, data:offset + *dest <- new _elem:type, capacity ] -def write chan:address:shared:channel:_elem, val:character -> chan:address:shared:channel:_elem [ +def write chan:address:shared:channel:_elem, val:_elem -> chan:address:shared:channel:_elem [ local-scope load-ingredients { @@ -58,9 +58,9 @@ def write chan:address:shared:channel:_elem, val:character -> chan:address:share wait-for-location *full-address } # store val - circular-buffer:address:shared:array:character <- get *chan, data:offset + circular-buffer:address:shared:array:_elem <- get *chan, data:offset free:address:number <- get-address *chan, first-free:offset - dest:address:character <- index-address *circular-buffer, *free + dest:address:_elem <- index-address *circular-buffer, *free *dest <- copy val # mark its slot as filled *free <- add *free, 1 @@ -73,7 +73,7 @@ def write chan:address:shared:channel:_elem, val:character -> chan:address:share } ] -def read chan:address:shared:channel:_elem -> result:character, chan:address:shared:channel:_elem [ +def read chan:address:shared:channel:_elem -> result:_elem, chan:address:shared:channel:_elem [ local-scope load-ingredients { @@ -85,7 +85,7 @@ def read chan:address:shared:channel:_elem -> result:character, chan:address:sha } # read result full:address:number <- get-address *chan, first-full:offset - circular-buffer:address:shared:array:character <- get *chan, data:offset + circular-buffer:address:shared:array:_elem <- get *chan, data:offset result <- index *circular-buffer, *full # mark its slot as empty *full <- add *full, 1 @@ -207,7 +207,7 @@ def channel-full? chan:address:shared:channel:_elem -> result:boolean [ def channel-capacity chan:address:shared:channel:_elem -> result:number [ local-scope load-ingredients - q:address:shared:array:character <- get *chan, data:offset + q:address:shared:array:_elem <- get *chan, data:offset result <- length *q ] |