diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-24 11:54:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-24 11:54:30 -0700 |
commit | b0bf5321de2ba32f3b92c2faf6b7b68a06b6b432 (patch) | |
tree | 9e0473bddd0d9a2d4aec7ac58dec8d85c2833a5d /channel.mu | |
parent | 15936c91a9f8023dc868a021029f84b45aa50176 (diff) | |
download | mu-b0bf5321de2ba32f3b92c2faf6b7b68a06b6b432.tar.gz |
2864 - replace all address:shared with just address
Now that we no longer have non-shared addresses, we can just always track refcounts for all addresses. Phew!
Diffstat (limited to 'channel.mu')
-rw-r--r-- | channel.mu | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/channel.mu b/channel.mu index 1dbae8e0..d74cbcad 100644 --- a/channel.mu +++ b/channel.mu @@ -1,6 +1,6 @@ # example program: communicating between routines using channels -def producer chan:address:shared:channel:character -> chan:address:shared:channel:character [ +def producer sink:address:sink:character -> sink:address:sink:character [ # produce characters 1 to 5 on a channel local-scope load-ingredients @@ -12,19 +12,19 @@ def producer chan:address:shared:channel:character -> chan:address:shared:channe # other threads might get between these prints $print [produce: ], n, [ ] - chan <- write chan, n + sink <- write sink, n n <- add n, 1 loop } ] -def consumer chan:address:shared:channel:character -> chan:address:shared:channel:character [ +def consumer source:address:source:character -> source:address:source:character [ # consume and print integers from a channel local-scope load-ingredients { # read an integer from the channel - n:character, chan <- read chan + n:character, source <- read source # other threads might get between these prints $print [consume: ], n:character, [ ] @@ -34,10 +34,10 @@ def consumer chan:address:shared:channel:character -> chan:address:shared:channe def main [ local-scope - chan:address:shared:channel:character <- new-channel 3 + source:address:source:character, sink:address:sink:character <- new-channel 3/capacity # create two background 'routines' that communicate by a channel - routine1:number <- start-running producer, chan - routine2:number <- start-running consumer, chan + routine1:number <- start-running producer, sink + routine2:number <- start-running consumer, source wait-for-routine routine1 wait-for-routine routine2 ] |