diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-25 22:27:19 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-25 22:27:19 -0700 |
commit | 32b8fac2799ac7cec613e84a3eb9c009141b6a3a (patch) | |
tree | 11f56c1a235abf7b626ea8983fff3d2edb1fcf98 /html/channel.mu.html | |
parent | 224972ee9871fcb06ee285fa5f3d9528c034d414 (diff) | |
download | mu-32b8fac2799ac7cec613e84a3eb9c009141b6a3a.tar.gz |
2866
Diffstat (limited to 'html/channel.mu.html')
-rw-r--r-- | html/channel.mu.html | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/html/channel.mu.html b/html/channel.mu.html index c320fdf2..30c5b5b7 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -32,7 +32,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <pre id='vimCodeElement'> <span class="Comment"># example program: communicating between routines using channels</span> -<span class="muRecipe">def</span> producer chan:address:shared:channel:character<span class="muRecipe"> -> </span>chan:address:shared:channel:character [ +<span class="muRecipe">def</span> producer sink:address:sink:character<span class="muRecipe"> -> </span>sink:address:sink:character [ <span class="Comment"># produce characters 1 to 5 on a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -44,19 +44,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[produce: ]</span>, n, <span class="Constant">[ </span> <span class="Constant">]</span> - chan<span class="Special"> <- </span>write chan, n + sink<span class="Special"> <- </span>write sink, n n<span class="Special"> <- </span>add n, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> consumer chan:address:shared:channel:character<span class="muRecipe"> -> </span>chan:address:shared:channel:character [ +<span class="muRecipe">def</span> consumer source:address:source:character<span class="muRecipe"> -> </span>source:address:source:character [ <span class="Comment"># consume and print integers from a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> - n:character, chan<span class="Special"> <- </span>read chan + n:character, source<span class="Special"> <- </span>read source <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[consume: ]</span>, n:character, <span class="Constant">[ </span> <span class="Constant">]</span> @@ -66,10 +66,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> main [ <span class="Constant">local-scope</span> - chan:address:shared:channel:character<span class="Special"> <- </span>new-channel <span class="Constant">3</span> + source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> <span class="Comment"># create two background 'routines' that communicate by a channel</span> - routine1:number<span class="Special"> <- </span>start-running producer, chan - routine2:number<span class="Special"> <- </span>start-running consumer, chan + routine1:number<span class="Special"> <- </span>start-running producer, sink + routine2:number<span class="Special"> <- </span>start-running consumer, source wait-for-routine routine1 wait-for-routine routine2 ] |