diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-09-07 10:37:27 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-09-07 10:37:27 -0700 |
commit | f5465e1220d73e237c51897b7d1211ec53b0dc04 (patch) | |
tree | 939ee8e57241b8515aede8106c6420e330ace75a /html/channel.mu.html | |
parent | 5ccf2653fb7d31b013f77df4e92e964e45c54f8a (diff) | |
download | mu-f5465e1220d73e237c51897b7d1211ec53b0dc04.tar.gz |
2177
Diffstat (limited to 'html/channel.mu.html')
-rw-r--r-- | html/channel.mu.html | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/html/channel.mu.html b/html/channel.mu.html index ce564ded..420eed5e 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -13,10 +13,12 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.Special { color: #ff6060; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } -.Underlined { color: #c000c0; text-decoration: underline; } -.Identifier { color: #804000; } +.Constant { color: #00a0a0; } +.Special { color: #ff6060; } +.Delimiter { color: #a04060; } +.muControl { color: #c0a020; } --> </style> @@ -30,44 +32,44 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <pre id='vimCodeElement'> <span class="Comment"># example program: communicating between routines using channels</span> -recipe producer [ +<span class="muRecipe">recipe</span> producer [ <span class="Comment"># produce numbers 1 to 5 on a channel</span> - <span class="Underlined">local</span>-scope - chan:address:channel<span class="Special"> <- </span>next-ingredient + <span class="Constant">local-scope</span> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># n = 0</span> - n:number<span class="Special"> <- </span><span class="Identifier">copy</span> 0 - { - done?:boolean<span class="Special"> <- </span>lesser-than n, 5 - break-unless done? + n:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Delimiter">{</span> + done?:boolean<span class="Special"> <- </span>lesser-than n, <span class="Constant">5</span> + <span class="muControl">break-unless</span> done? <span class="Comment"># other threads might get between these prints</span> - $<span class="Identifier">print</span> [produce: ], n, [ -] - chan:address:channel<span class="Special"> <- </span><span class="Identifier">write</span> chan, n - n<span class="Special"> <- </span>add n, 1 - loop - } + $print <span class="Constant">[produce: ]</span>, n, <span class="Constant">[ </span> +<span class="Constant">]</span> + chan:address:channel<span class="Special"> <- </span>write chan, n + n<span class="Special"> <- </span>add n, <span class="Constant">1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> ] -recipe consumer [ +<span class="muRecipe">recipe</span> consumer [ <span class="Comment"># consume and print integers from a channel</span> - <span class="Underlined">local</span>-scope - chan:address:channel<span class="Special"> <- </span>next-ingredient - { + <span class="Constant">local-scope</span> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> - n:number, chan:address:channel<span class="Special"> <- </span><span class="Identifier">read</span> chan + n:number, chan:address:channel<span class="Special"> <- </span>read chan <span class="Comment"># other threads might get between these prints</span> - $<span class="Identifier">print</span> [consume: ], n:number, [ -] - loop - } + $print <span class="Constant">[consume: ]</span>, n:number, <span class="Constant">[ </span> +<span class="Constant">]</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> ] -recipe main [ - <span class="Underlined">local</span>-scope - chan:address:channel<span class="Special"> <- </span><span class="Identifier">new</span>-channel 3 +<span class="muRecipe">recipe</span> main [ + <span class="Constant">local-scope</span> + chan:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3</span> <span class="Comment"># create two background 'routines' that communicate by a channel</span> - routine1:number<span class="Special"> <- </span>start-running producer:recipe, chan - routine2:number<span class="Special"> <- </span>start-running consumer:recipe, chan + routine1:number<span class="Special"> <- </span>start-running <span class="Constant">producer:recipe</span>, chan + routine2:number<span class="Special"> <- </span>start-running <span class="Constant">consumer:recipe</span>, chan wait-for-routine routine1 wait-for-routine routine2 ] |