diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2018-01-27 00:28:51 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2018-01-27 00:28:51 -0800 |
commit | b301e0c0e6b54dceecbe4ee1ef8f610411015c30 (patch) | |
tree | d40803d412718221d7c92fd50c189563877b8301 /html/075channel.mu.html | |
parent | 805d58c6aeeeba3e4989c0eed6781b3861e8fae0 (diff) | |
download | mu-b301e0c0e6b54dceecbe4ee1ef8f610411015c30.tar.gz |
4200
Forgot to set up exuberant_ctags_rc as .ctags on new laptop.
Diffstat (limited to 'html/075channel.mu.html')
-rw-r--r-- | html/075channel.mu.html | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/html/075channel.mu.html b/html/075channel.mu.html index 571f8959..6d3b267a 100644 --- a/html/075channel.mu.html +++ b/html/075channel.mu.html @@ -80,9 +80,9 @@ if ('onhashchange' in window) { <span id="L17" class="LineNr"> 17 </span><span class="muScenario">scenario</span> channel [ <span id="L18" class="LineNr"> 18 </span> run [ <span id="L19" class="LineNr"> 19 </span> <span class="Constant">local-scope</span> -<span id="L20" class="LineNr"> 20 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> -<span id="L21" class="LineNr"> 21 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> -<span id="L22" class="LineNr"> 22 </span> 10:num/<span class="Special">raw</span>, 11:bool/<span class="Special">raw</span>, source <span class="Special"><-</span> read source +<span id="L20" class="LineNr"> 20 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> +<span id="L21" class="LineNr"> 21 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> +<span id="L22" class="LineNr"> 22 </span> 10:num/<span class="Special">raw</span>, 11:bool/<span class="Special">raw</span>, <a href='075channel.mu.html#L43'>source</a> <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> <span id="L23" class="LineNr"> 23 </span> ] <span id="L24" class="LineNr"> 24 </span> memory-should-contain [ <span id="L25" class="LineNr"> 25 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 34</span> @@ -103,22 +103,22 @@ if ('onhashchange' in window) { <span id="L40" class="LineNr"> 40 </span><span class="Comment"># Since channels have two ends, and since it's an error to use either end from</span> <span id="L41" class="LineNr"> 41 </span><span class="Comment"># multiple routines, let's distinguish the ends.</span> <span id="L42" class="LineNr"> 42 </span> -<span id="L43" class="LineNr"> 43 </span><span class="muData">container</span> source:_elem [ +<span id="L43" class="LineNr"> 43 </span><span class="muData">container</span> <a href='075channel.mu.html#L43'>source</a>:_elem [ <span id="L44" class="LineNr"> 44 </span> chan:&:channel:_elem <span id="L45" class="LineNr"> 45 </span>] <span id="L46" class="LineNr"> 46 </span> -<span id="L47" class="LineNr"> 47 </span><span class="muData">container</span> sink:_elem [ +<span id="L47" class="LineNr"> 47 </span><span class="muData">container</span> <a href='075channel.mu.html#L47'>sink</a>:_elem [ <span id="L48" class="LineNr"> 48 </span> chan:&:channel:_elem <span id="L49" class="LineNr"> 49 </span>] <span id="L50" class="LineNr"> 50 </span> -<span id="L51" class="LineNr"> 51 </span><span class="muRecipe">def</span> new-channel capacity:num<span class="muRecipe"> -> </span>in:&:source:_elem, out:&:sink:_elem [ +<span id="L51" class="LineNr"> 51 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L51'>new-channel</a> <a href='075channel.mu.html#L399'>capacity</a>:num<span class="muRecipe"> -> </span>in:&:<a href='075channel.mu.html#L43'>source</a>:_elem, out:&:<a href='075channel.mu.html#L47'>sink</a>:_elem [ <span id="L52" class="LineNr"> 52 </span> <span class="Constant">local-scope</span> <span id="L53" class="LineNr"> 53 </span> <span class="Constant">load-inputs</span> <span id="L54" class="LineNr"> 54 </span> result:&:channel:_elem <span class="Special"><-</span> new <span class="Delimiter">{</span>(channel _elem): type<span class="Delimiter">}</span> <span id="L55" class="LineNr"> 55 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">first-full:offset</span>,<span class="Constant"> 0</span> <span id="L56" class="LineNr"> 56 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">first-free:offset</span>,<span class="Constant"> 0</span> -<span id="L57" class="LineNr"> 57 </span> capacity <span class="Special"><-</span> add capacity,<span class="Constant"> 1</span> <span class="Comment"># unused slot for 'full?' below</span> -<span id="L58" class="LineNr"> 58 </span> data:&:@:_elem <span class="Special"><-</span> new <span class="Constant">_elem:type</span>, capacity +<span id="L57" class="LineNr"> 57 </span> <a href='075channel.mu.html#L399'>capacity</a> <span class="Special"><-</span> add <a href='075channel.mu.html#L399'>capacity</a>,<span class="Constant"> 1</span> <span class="Comment"># unused slot for 'full?' below</span> +<span id="L58" class="LineNr"> 58 </span> data:&:@:_elem <span class="Special"><-</span> new <span class="Constant">_elem:type</span>, <a href='075channel.mu.html#L399'>capacity</a> <span id="L59" class="LineNr"> 59 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">data:offset</span>, data <span id="L60" class="LineNr"> 60 </span> in <span class="Special"><-</span> new <span class="Delimiter">{</span>(source _elem): type<span class="Delimiter">}</span> <span id="L61" class="LineNr"> 61 </span> *in <span class="Special"><-</span> put *in, <span class="Constant">chan:offset</span>, result @@ -127,12 +127,12 @@ if ('onhashchange' in window) { <span id="L64" class="LineNr"> 64 </span>] <span id="L65" class="LineNr"> 65 </span> <span id="L66" class="LineNr"> 66 </span><span class="Comment"># write a value to a channel</span> -<span id="L67" class="LineNr"> 67 </span><span class="muRecipe">def</span> write out:&:sink:_elem, val:_elem<span class="muRecipe"> -> </span>out:&:sink:_elem [ +<span id="L67" class="LineNr"> 67 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L67'>write</a> out:&:<a href='075channel.mu.html#L47'>sink</a>:_elem, val:_elem<span class="muRecipe"> -> </span>out:&:<a href='075channel.mu.html#L47'>sink</a>:_elem [ <span id="L68" class="LineNr"> 68 </span> <span class="Constant">local-scope</span> <span id="L69" class="LineNr"> 69 </span> <span class="Constant">load-inputs</span> <span id="L70" class="LineNr"> 70 </span> assert out, <span class="Constant">[write to null channel]</span> <span id="L71" class="LineNr"> 71 </span> chan:&:channel:_elem <span class="Special"><-</span> get *out, <span class="Constant">chan:offset</span> -<span id="L72" class="LineNr"> 72 </span><span class="Constant"> <channel-write-initial></span> +<span id="L72" class="LineNr"> 72 </span><span class="Constant"> <a href='075channel.mu.html#L72'><channel-write-initial></a></span> <span id="L73" class="LineNr"> 73 </span> <span class="Comment"># block until lock is acquired AND queue has room</span> <span id="L74" class="LineNr"> 74 </span> lock:location <span class="Special"><-</span> get-location *chan, <span class="Constant">lock:offset</span> <span id="L75" class="LineNr"> 75 </span><span class="CommentedCode">#? $print [write], 10/newline</span> @@ -140,7 +140,7 @@ if ('onhashchange' in window) { <span id="L77" class="LineNr"> 77 </span><span class="CommentedCode">#? $print [trying to acquire lock for writing], 10/newline</span> <span id="L78" class="LineNr"> 78 </span> wait-for-reset-then-set lock <span id="L79" class="LineNr"> 79 </span><span class="CommentedCode">#? $print [lock acquired for writing], 10/newline</span> -<span id="L80" class="LineNr"> 80 </span> full?:bool <span class="Special"><-</span> channel-full? chan +<span id="L80" class="LineNr"> 80 </span> full?:bool <span class="Special"><-</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan <span id="L81" class="LineNr"> 81 </span> <span class="muControl">break-unless</span> full? <span id="L82" class="LineNr"> 82 </span><span class="CommentedCode">#? $print [but channel is full; relinquishing lock], 10/newline</span> <span id="L83" class="LineNr"> 83 </span> <span class="Comment"># channel is full; relinquish lock and give a reader the opportunity to</span> @@ -173,7 +173,7 @@ if ('onhashchange' in window) { <span id="L110" class="LineNr">110 </span>] <span id="L111" class="LineNr">111 </span> <span id="L112" class="LineNr">112 </span><span class="Comment"># read a value from a channel</span> -<span id="L113" class="LineNr">113 </span><span class="muRecipe">def</span> read in:&:source:_elem<span class="muRecipe"> -> </span>result:_elem, eof?:bool, in:&:source:_elem [ +<span id="L113" class="LineNr">113 </span><span class="muRecipe">def</span> read in:&:<a href='075channel.mu.html#L43'>source</a>:_elem<span class="muRecipe"> -> </span>result:_elem, eof?:bool, in:&:<a href='075channel.mu.html#L43'>source</a>:_elem [ <span id="L114" class="LineNr">114 </span> <span class="Constant">local-scope</span> <span id="L115" class="LineNr">115 </span> <span class="Constant">load-inputs</span> <span id="L116" class="LineNr">116 </span> assert in, <span class="Constant">[read on null channel]</span> @@ -186,14 +186,14 @@ if ('onhashchange' in window) { <span id="L123" class="LineNr">123 </span><span class="CommentedCode">#? $print [trying to acquire lock for reading], 10/newline</span> <span id="L124" class="LineNr">124 </span> wait-for-reset-then-set lock <span id="L125" class="LineNr">125 </span><span class="CommentedCode">#? $print [lock acquired for reading], 10/newline</span> -<span id="L126" class="LineNr">126 </span> empty?:bool <span class="Special"><-</span> channel-empty? chan +<span id="L126" class="LineNr">126 </span> empty?:bool <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan <span id="L127" class="LineNr">127 </span> <span class="muControl">break-unless</span> empty? <span id="L128" class="LineNr">128 </span><span class="CommentedCode">#? $print [but channel is empty; relinquishing lock], 10/newline</span> <span id="L129" class="LineNr">129 </span> <span class="Comment"># channel is empty; relinquish lock and give a writer the opportunity to</span> <span id="L130" class="LineNr">130 </span> <span class="Comment"># add to it</span> <span id="L131" class="LineNr">131 </span> reset lock <span id="L132" class="LineNr">132 </span> current-routine-is-blocked -<span id="L133" class="LineNr">133 </span><span class="Constant"> <channel-read-empty></span> +<span id="L133" class="LineNr">133 </span><span class="Constant"> <a href='075channel.mu.html#L133'><channel-read-empty></a></span> <span id="L134" class="LineNr">134 </span> switch <span class="Comment"># avoid spinlocking</span> <span id="L135" class="LineNr">135 </span> <span class="muControl"> loop</span> <span id="L136" class="LineNr">136 </span> <span class="Delimiter">}</span> @@ -226,7 +226,7 @@ if ('onhashchange' in window) { <span id="L163" class="LineNr">163 </span><span class="muScenario">scenario</span> channel-initialization [ <span id="L164" class="LineNr">164 </span> run [ <span id="L165" class="LineNr">165 </span> <span class="Constant">local-scope</span> -<span id="L166" class="LineNr">166 </span> source:&:source:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> +<span id="L166" class="LineNr">166 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> <span id="L167" class="LineNr">167 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> <span id="L168" class="LineNr">168 </span> 10:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-full:offset</span> <span id="L169" class="LineNr">169 </span> 11:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> @@ -239,9 +239,9 @@ if ('onhashchange' in window) { <span id="L176" class="LineNr">176 </span> <span id="L177" class="LineNr">177 </span><span class="muScenario">scenario</span> channel-write-increments-free [ <span id="L178" class="LineNr">178 </span> <span class="Constant">local-scope</span> -<span id="L179" class="LineNr">179 </span> _, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> +<span id="L179" class="LineNr">179 </span> _, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> <span id="L180" class="LineNr">180 </span> run [ -<span id="L181" class="LineNr">181 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> +<span id="L181" class="LineNr">181 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> <span id="L182" class="LineNr">182 </span> chan:&:channel:num <span class="Special"><-</span> get *sink, <span class="Constant">chan:offset</span> <span id="L183" class="LineNr">183 </span> 10:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-full:offset</span> <span id="L184" class="LineNr">184 </span> 11:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> @@ -254,10 +254,10 @@ if ('onhashchange' in window) { <span id="L191" class="LineNr">191 </span> <span id="L192" class="LineNr">192 </span><span class="muScenario">scenario</span> channel-read-increments-full [ <span id="L193" class="LineNr">193 </span> <span class="Constant">local-scope</span> -<span id="L194" class="LineNr">194 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> -<span id="L195" class="LineNr">195 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> +<span id="L194" class="LineNr">194 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> +<span id="L195" class="LineNr">195 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> <span id="L196" class="LineNr">196 </span> run [ -<span id="L197" class="LineNr">197 </span> _, _, source <span class="Special"><-</span> read source +<span id="L197" class="LineNr">197 </span> _, _, <a href='075channel.mu.html#L43'>source</a> <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> <span id="L198" class="LineNr">198 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> <span id="L199" class="LineNr">199 </span> 10:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-full:offset</span> <span id="L200" class="LineNr">200 </span> 11:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> @@ -271,20 +271,20 @@ if ('onhashchange' in window) { <span id="L208" class="LineNr">208 </span><span class="muScenario">scenario</span> channel-wrap [ <span id="L209" class="LineNr">209 </span> <span class="Constant">local-scope</span> <span id="L210" class="LineNr">210 </span> <span class="Comment"># channel with just 1 slot</span> -<span id="L211" class="LineNr">211 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">1/capacity</span> +<span id="L211" class="LineNr">211 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">1/capacity</span> <span id="L212" class="LineNr">212 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> <span id="L213" class="LineNr">213 </span> <span class="Comment"># write and read a value</span> -<span id="L214" class="LineNr">214 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> -<span id="L215" class="LineNr">215 </span> _, _, source <span class="Special"><-</span> read source +<span id="L214" class="LineNr">214 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> +<span id="L215" class="LineNr">215 </span> _, _, <a href='075channel.mu.html#L43'>source</a> <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> <span id="L216" class="LineNr">216 </span> run [ <span id="L217" class="LineNr">217 </span> <span class="Comment"># first-free will now be 1</span> <span id="L218" class="LineNr">218 </span> 10:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> <span id="L219" class="LineNr">219 </span> 11:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> <span id="L220" class="LineNr">220 </span> <span class="Comment"># write second value, verify that first-free wraps</span> -<span id="L221" class="LineNr">221 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> +<span id="L221" class="LineNr">221 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> <span id="L222" class="LineNr">222 </span> 20:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-free:offset</span> <span id="L223" class="LineNr">223 </span> <span class="Comment"># read second value, verify that first-full wraps</span> -<span id="L224" class="LineNr">224 </span> _, _, source <span class="Special"><-</span> read source +<span id="L224" class="LineNr">224 </span> _, _, <a href='075channel.mu.html#L43'>source</a> <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> <span id="L225" class="LineNr">225 </span> 30:num/<span class="Special">raw</span> <span class="Special"><-</span> get *chan, <span class="Constant">first-full:offset</span> <span id="L226" class="LineNr">226 </span> ] <span id="L227" class="LineNr">227 </span> memory-should-contain [ @@ -298,10 +298,10 @@ if ('onhashchange' in window) { <span id="L235" class="LineNr">235 </span><span class="muScenario">scenario</span> channel-new-empty-not-full [ <span id="L236" class="LineNr">236 </span> run [ <span id="L237" class="LineNr">237 </span> <span class="Constant">local-scope</span> -<span id="L238" class="LineNr">238 </span> source:&:source:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> +<span id="L238" class="LineNr">238 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> <span id="L239" class="LineNr">239 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> -<span id="L240" class="LineNr">240 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-empty? chan -<span id="L241" class="LineNr">241 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-full? chan +<span id="L240" class="LineNr">240 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan +<span id="L241" class="LineNr">241 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan <span id="L242" class="LineNr">242 </span> ] <span id="L243" class="LineNr">243 </span> memory-should-contain [ <span id="L244" class="LineNr">244 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># empty?</span> @@ -311,12 +311,12 @@ if ('onhashchange' in window) { <span id="L248" class="LineNr">248 </span> <span id="L249" class="LineNr">249 </span><span class="muScenario">scenario</span> channel-write-not-empty [ <span id="L250" class="LineNr">250 </span> <span class="Constant">local-scope</span> -<span id="L251" class="LineNr">251 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> +<span id="L251" class="LineNr">251 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> <span id="L252" class="LineNr">252 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> <span id="L253" class="LineNr">253 </span> run [ -<span id="L254" class="LineNr">254 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> -<span id="L255" class="LineNr">255 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-empty? chan -<span id="L256" class="LineNr">256 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-full? chan +<span id="L254" class="LineNr">254 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> +<span id="L255" class="LineNr">255 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan +<span id="L256" class="LineNr">256 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan <span id="L257" class="LineNr">257 </span> ] <span id="L258" class="LineNr">258 </span> memory-should-contain [ <span id="L259" class="LineNr">259 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># empty?</span> @@ -326,12 +326,12 @@ if ('onhashchange' in window) { <span id="L263" class="LineNr">263 </span> <span id="L264" class="LineNr">264 </span><span class="muScenario">scenario</span> channel-write-full [ <span id="L265" class="LineNr">265 </span> <span class="Constant">local-scope</span> -<span id="L266" class="LineNr">266 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">1/capacity</span> +<span id="L266" class="LineNr">266 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">1/capacity</span> <span id="L267" class="LineNr">267 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> <span id="L268" class="LineNr">268 </span> run [ -<span id="L269" class="LineNr">269 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> -<span id="L270" class="LineNr">270 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-empty? chan -<span id="L271" class="LineNr">271 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-full? chan +<span id="L269" class="LineNr">269 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> +<span id="L270" class="LineNr">270 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan +<span id="L271" class="LineNr">271 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan <span id="L272" class="LineNr">272 </span> ] <span id="L273" class="LineNr">273 </span> memory-should-contain [ <span id="L274" class="LineNr">274 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># empty?</span> @@ -341,13 +341,13 @@ if ('onhashchange' in window) { <span id="L278" class="LineNr">278 </span> <span id="L279" class="LineNr">279 </span><span class="muScenario">scenario</span> channel-read-not-full [ <span id="L280" class="LineNr">280 </span> <span class="Constant">local-scope</span> -<span id="L281" class="LineNr">281 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">1/capacity</span> +<span id="L281" class="LineNr">281 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">1/capacity</span> <span id="L282" class="LineNr">282 </span> chan:&:channel:num <span class="Special"><-</span> get *source, <span class="Constant">chan:offset</span> -<span id="L283" class="LineNr">283 </span> sink <span class="Special"><-</span> write sink,<span class="Constant"> 34</span> +<span id="L283" class="LineNr">283 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 34</span> <span id="L284" class="LineNr">284 </span> run [ -<span id="L285" class="LineNr">285 </span> _, _, source <span class="Special"><-</span> read source -<span id="L286" class="LineNr">286 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-empty? chan -<span id="L287" class="LineNr">287 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-full? chan +<span id="L285" class="LineNr">285 </span> _, _, <a href='075channel.mu.html#L43'>source</a> <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> +<span id="L286" class="LineNr">286 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan +<span id="L287" class="LineNr">287 </span> 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan <span id="L288" class="LineNr">288 </span> ] <span id="L289" class="LineNr">289 </span> memory-should-contain [ <span id="L290" class="LineNr">290 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># empty?</span> @@ -358,26 +358,26 @@ if ('onhashchange' in window) { <span id="L295" class="LineNr">295 </span><span class="muScenario">scenario</span> channel-clear [ <span id="L296" class="LineNr">296 </span> <span class="Constant">local-scope</span> <span id="L297" class="LineNr">297 </span> <span class="Comment"># create a channel with a few items</span> -<span id="L298" class="LineNr">298 </span> source:&:source:num, sink:&:sink:num <span class="Special"><-</span> new-channel <span class="Constant">3/capacity</span> +<span id="L298" class="LineNr">298 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:num, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:num <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">3/capacity</span> <span id="L299" class="LineNr">299 </span> chan:&:channel:num <span class="Special"><-</span> get *sink, <span class="Constant">chan:offset</span> -<span id="L300" class="LineNr">300 </span> write sink,<span class="Constant"> 30</span> -<span id="L301" class="LineNr">301 </span> write sink,<span class="Constant"> 31</span> -<span id="L302" class="LineNr">302 </span> write sink,<span class="Constant"> 32</span> +<span id="L300" class="LineNr">300 </span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 30</span> +<span id="L301" class="LineNr">301 </span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 31</span> +<span id="L302" class="LineNr">302 </span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>,<span class="Constant"> 32</span> <span id="L303" class="LineNr">303 </span> run [ -<span id="L304" class="LineNr">304 </span> clear source -<span id="L305" class="LineNr">305 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> channel-empty? chan +<span id="L304" class="LineNr">304 </span> <a href='075channel.mu.html#L312'>clear</a> <a href='075channel.mu.html#L43'>source</a> +<span id="L305" class="LineNr">305 </span> 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan <span id="L306" class="LineNr">306 </span> ] <span id="L307" class="LineNr">307 </span> memory-should-contain [ <span id="L308" class="LineNr">308 </span> <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># after the call to 'clear', the channel should be empty</span> <span id="L309" class="LineNr">309 </span> ] <span id="L310" class="LineNr">310 </span>] <span id="L311" class="LineNr">311 </span> -<span id="L312" class="LineNr">312 </span><span class="muRecipe">def</span> clear in:&:source:_elem<span class="muRecipe"> -> </span>in:&:source:_elem [ +<span id="L312" class="LineNr">312 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L312'>clear</a> in:&:<a href='075channel.mu.html#L43'>source</a>:_elem<span class="muRecipe"> -> </span>in:&:<a href='075channel.mu.html#L43'>source</a>:_elem [ <span id="L313" class="LineNr">313 </span> <span class="Constant">local-scope</span> <span id="L314" class="LineNr">314 </span> <span class="Constant">load-inputs</span> <span id="L315" class="LineNr">315 </span> chan:&:channel:_elem <span class="Special"><-</span> get *in, <span class="Constant">chan:offset</span> <span id="L316" class="LineNr">316 </span> <span class="Delimiter">{</span> -<span id="L317" class="LineNr">317 </span> empty?:bool <span class="Special"><-</span> channel-empty? chan +<span id="L317" class="LineNr">317 </span> empty?:bool <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan <span id="L318" class="LineNr">318 </span> <span class="muControl">break-if</span> empty? <span id="L319" class="LineNr">319 </span> _, _, in <span class="Special"><-</span> read in <span id="L320" class="LineNr">320 </span> <span class="muControl"> loop</span> @@ -394,13 +394,13 @@ if ('onhashchange' in window) { <span id="L331" class="LineNr">331 </span> <span id="L332" class="LineNr">332 </span><span class="Comment"># a channel can be closed from either the source or the sink</span> <span id="L333" class="LineNr">333 </span><span class="Comment"># both routines can modify the 'closed?' bit, but they can only ever set it, so this is a benign race</span> -<span id="L334" class="LineNr">334 </span><span class="muRecipe">def</span> close x:&:source:_elem<span class="muRecipe"> -> </span>x:&:source:_elem [ +<span id="L334" class="LineNr">334 </span><span class="muRecipe">def</span> close x:&:<a href='075channel.mu.html#L43'>source</a>:_elem<span class="muRecipe"> -> </span>x:&:<a href='075channel.mu.html#L43'>source</a>:_elem [ <span id="L335" class="LineNr">335 </span> <span class="Constant">local-scope</span> <span id="L336" class="LineNr">336 </span> <span class="Constant">load-inputs</span> <span id="L337" class="LineNr">337 </span> chan:&:channel:_elem <span class="Special"><-</span> get *x, <span class="Constant">chan:offset</span> <span id="L338" class="LineNr">338 </span> *chan <span class="Special"><-</span> put *chan, <span class="Constant">closed?:offset</span>, <span class="Constant">1/true</span> <span id="L339" class="LineNr">339 </span>] -<span id="L340" class="LineNr">340 </span><span class="muRecipe">def</span> close x:&:sink:_elem<span class="muRecipe"> -> </span>x:&:sink:_elem [ +<span id="L340" class="LineNr">340 </span><span class="muRecipe">def</span> close x:&:<a href='075channel.mu.html#L47'>sink</a>:_elem<span class="muRecipe"> -> </span>x:&:<a href='075channel.mu.html#L47'>sink</a>:_elem [ <span id="L341" class="LineNr">341 </span> <span class="Constant">local-scope</span> <span id="L342" class="LineNr">342 </span> <span class="Constant">load-inputs</span> <span id="L343" class="LineNr">343 </span> chan:&:channel:_elem <span class="Special"><-</span> get *x, <span class="Constant">chan:offset</span> @@ -413,11 +413,11 @@ if ('onhashchange' in window) { <span id="L350" class="LineNr">350 </span><span class="Comment"># if a channel is closed for writing,</span> <span id="L351" class="LineNr">351 </span><span class="Comment"># future reads continue until the channel empties,</span> <span id="L352" class="LineNr">352 </span><span class="Comment"># then the channel is also closed for reading</span> -<span id="L353" class="LineNr">353 </span><span class="muRecipe">after</span> <span class="Constant"><channel-write-initial></span> [ +<span id="L353" class="LineNr">353 </span><span class="muRecipe">after</span> <span class="Constant"><a href='075channel.mu.html#L72'><channel-write-initial></a></span> [ <span id="L354" class="LineNr">354 </span> closed?:bool <span class="Special"><-</span> get *chan, <span class="Constant">closed?:offset</span> <span id="L355" class="LineNr">355 </span> <span class="muControl">return-if</span> closed? <span id="L356" class="LineNr">356 </span>] -<span id="L357" class="LineNr">357 </span><span class="muRecipe">after</span> <span class="Constant"><channel-read-empty></span> [ +<span id="L357" class="LineNr">357 </span><span class="muRecipe">after</span> <span class="Constant"><a href='075channel.mu.html#L133'><channel-read-empty></a></span> [ <span id="L358" class="LineNr">358 </span> closed?:bool <span class="Special"><-</span> get *chan, <span class="Constant">closed?:offset</span> <span id="L359" class="LineNr">359 </span> <span class="Delimiter">{</span> <span id="L360" class="LineNr">360 </span> <span class="muControl">break-unless</span> closed? @@ -430,7 +430,7 @@ if ('onhashchange' in window) { <span id="L367" class="LineNr">367 </span><span class="SalientComment">## helpers</span> <span id="L368" class="LineNr">368 </span> <span id="L369" class="LineNr">369 </span><span class="Comment"># An empty channel has first-free and first-full both at the same value.</span> -<span id="L370" class="LineNr">370 </span><span class="muRecipe">def</span> channel-empty? chan:&:channel:_elem<span class="muRecipe"> -> </span>result:bool [ +<span id="L370" class="LineNr">370 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L370'>channel-empty?</a> chan:&:channel:_elem<span class="muRecipe"> -> </span>result:bool [ <span id="L371" class="LineNr">371 </span> <span class="Constant">local-scope</span> <span id="L372" class="LineNr">372 </span> <span class="Constant">load-inputs</span> <span id="L373" class="LineNr">373 </span> <span class="Comment"># return chan.first-full == chan.first-free</span> @@ -441,7 +441,7 @@ if ('onhashchange' in window) { <span id="L378" class="LineNr">378 </span> <span id="L379" class="LineNr">379 </span><span class="Comment"># A full channel has first-free just before first-full, wasting one slot.</span> <span id="L380" class="LineNr">380 </span><span class="Comment"># (Other alternatives: <a href="https://www.snellman.net/blog/archive/2016-12-13-ring-buffers">https://www.snellman.net/blog/archive/2016-12-13-ring-buffers</a>)</span> -<span id="L381" class="LineNr">381 </span><span class="muRecipe">def</span> channel-full? chan:&:channel:_elem<span class="muRecipe"> -> </span>result:bool [ +<span id="L381" class="LineNr">381 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L381'>channel-full?</a> chan:&:channel:_elem<span class="muRecipe"> -> </span>result:bool [ <span id="L382" class="LineNr">382 </span> <span class="Constant">local-scope</span> <span id="L383" class="LineNr">383 </span> <span class="Constant">load-inputs</span> <span id="L384" class="LineNr">384 </span> <span class="Comment"># tmp = chan.first-free + 1</span> @@ -449,7 +449,7 @@ if ('onhashchange' in window) { <span id="L386" class="LineNr">386 </span> tmp <span class="Special"><-</span> add tmp,<span class="Constant"> 1</span> <span id="L387" class="LineNr">387 </span> <span class="Delimiter">{</span> <span id="L388" class="LineNr">388 </span> <span class="Comment"># if tmp == chan.capacity, tmp = 0</span> -<span id="L389" class="LineNr">389 </span> len:num <span class="Special"><-</span> capacity chan +<span id="L389" class="LineNr">389 </span> len:num <span class="Special"><-</span> <a href='075channel.mu.html#L399'>capacity</a> chan <span id="L390" class="LineNr">390 </span> at-end?:bool <span class="Special"><-</span> greater-or-equal tmp, len <span id="L391" class="LineNr">391 </span> <span class="muControl">break-unless</span> at-end? <span id="L392" class="LineNr">392 </span> tmp <span class="Special"><-</span> copy<span class="Constant"> 0</span> @@ -459,7 +459,7 @@ if ('onhashchange' in window) { <span id="L396" class="LineNr">396 </span> result <span class="Special"><-</span> equal full, tmp <span id="L397" class="LineNr">397 </span>] <span id="L398" class="LineNr">398 </span> -<span id="L399" class="LineNr">399 </span><span class="muRecipe">def</span> capacity chan:&:channel:_elem<span class="muRecipe"> -> </span>result:num [ +<span id="L399" class="LineNr">399 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L399'>capacity</a> chan:&:channel:_elem<span class="muRecipe"> -> </span>result:num [ <span id="L400" class="LineNr">400 </span> <span class="Constant">local-scope</span> <span id="L401" class="LineNr">401 </span> <span class="Constant">load-inputs</span> <span id="L402" class="LineNr">402 </span> q:&:@:_elem <span class="Special"><-</span> get *chan, <span class="Constant">data:offset</span> @@ -468,13 +468,13 @@ if ('onhashchange' in window) { <span id="L405" class="LineNr">405 </span> <span id="L406" class="LineNr">406 </span><span class="SalientComment">## helpers for channels of characters in particular</span> <span id="L407" class="LineNr">407 </span> -<span id="L408" class="LineNr">408 </span><span class="muRecipe">def</span> buffer-lines in:&:source:char, buffered-out:&:sink:char<span class="muRecipe"> -> </span>buffered-out:&:sink:char, in:&:source:char [ +<span id="L408" class="LineNr">408 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L408'>buffer-lines</a> in:&:<a href='075channel.mu.html#L43'>source</a>:char, buffered-out:&:<a href='075channel.mu.html#L47'>sink</a>:char<span class="muRecipe"> -> </span>buffered-out:&:<a href='075channel.mu.html#L47'>sink</a>:char, in:&:<a href='075channel.mu.html#L43'>source</a>:char [ <span id="L409" class="LineNr">409 </span> <span class="Constant">local-scope</span> <span id="L410" class="LineNr">410 </span> <span class="Constant">load-inputs</span> <span id="L411" class="LineNr">411 </span> <span class="Comment"># repeat forever</span> <span id="L412" class="LineNr">412 </span> eof?:bool <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span id="L413" class="LineNr">413 </span> <span class="Delimiter">{</span> -<span id="L414" class="LineNr">414 </span> line:&:buffer:char <span class="Special"><-</span> new-buffer<span class="Constant"> 30</span> +<span id="L414" class="LineNr">414 </span> line:&:<a href='061text.mu.html#L120'>buffer</a>:char <span class="Special"><-</span> <a href='061text.mu.html#L125'>new-buffer</a><span class="Constant"> 30</span> <span id="L415" class="LineNr">415 </span> <span class="Comment"># read characters from 'in' until newline, copy into line</span> <span id="L416" class="LineNr">416 </span> <span class="Delimiter">{</span> <span id="L417" class="LineNr">417 </span><span class="Constant"> +next-character</span> @@ -510,7 +510,7 @@ if ('onhashchange' in window) { <span id="L447" class="LineNr">447 </span> done?:bool <span class="Special"><-</span> greater-or-equal i, max <span id="L448" class="LineNr">448 </span> <span class="muControl">break-if</span> done? <span id="L449" class="LineNr">449 </span> c:char <span class="Special"><-</span> index *line-contents, i -<span id="L450" class="LineNr">450 </span> buffered-out <span class="Special"><-</span> write buffered-out, c +<span id="L450" class="LineNr">450 </span> buffered-out <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> buffered-out, c <span id="L451" class="LineNr">451 </span> i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span id="L452" class="LineNr">452 </span> <span class="muControl"> loop</span> <span id="L453" class="LineNr">453 </span> <span class="Delimiter">}</span> @@ -526,37 +526,37 @@ if ('onhashchange' in window) { <span id="L463" class="LineNr">463 </span><span class="muScenario">scenario</span> buffer-lines-blocks-until-newline [ <span id="L464" class="LineNr">464 </span> run [ <span id="L465" class="LineNr">465 </span> <span class="Constant">local-scope</span> -<span id="L466" class="LineNr">466 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> new-channel <span class="Constant">10/capacity</span> -<span id="L467" class="LineNr">467 </span> _, buffered-stdin:&:sink:char/buffered-stdin <span class="Special"><-</span> new-channel <span class="Constant">10/capacity</span> +<span id="L466" class="LineNr">466 </span> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:char, <a href='075channel.mu.html#L47'>sink</a>:&:<a href='075channel.mu.html#L47'>sink</a>:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">10/capacity</span> +<span id="L467" class="LineNr">467 </span> _, buffered-stdin:&:<a href='075channel.mu.html#L47'>sink</a>:char/buffered-stdin <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">10/capacity</span> <span id="L468" class="LineNr">468 </span> buffered-chan:&:channel:char <span class="Special"><-</span> get *buffered-stdin, <span class="Constant">chan:offset</span> -<span id="L469" class="LineNr">469 </span> empty?:bool <span class="Special"><-</span> channel-empty? buffered-chan +<span id="L469" class="LineNr">469 </span> empty?:bool <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> buffered-chan <span id="L470" class="LineNr">470 </span> assert empty?, <span class="Constant">[ </span> <span id="L471" class="LineNr">471 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after init]</span> <span id="L472" class="LineNr">472 </span> <span class="Comment"># buffer stdin into buffered-stdin, try to read from buffered-stdin</span> -<span id="L473" class="LineNr">473 </span> buffer-routine:num <span class="Special"><-</span> <span class="muControl">start-running</span> buffer-lines, source, buffered-stdin +<span id="L473" class="LineNr">473 </span> buffer-routine:num <span class="Special"><-</span> <span class="muControl">start-running</span> <a href='075channel.mu.html#L408'>buffer-lines</a>, <a href='075channel.mu.html#L43'>source</a>, buffered-stdin <span id="L474" class="LineNr">474 </span> wait-for-routine-to-block buffer-routine -<span id="L475" class="LineNr">475 </span> empty? <span class="Special"><-</span> channel-empty? buffered-chan +<span id="L475" class="LineNr">475 </span> empty? <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> buffered-chan <span id="L476" class="LineNr">476 </span> assert empty?:bool, <span class="Constant">[ </span> -<span id="L477" class="LineNr">477 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up]</span> +<span id="L477" class="LineNr">477 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after <a href='075channel.mu.html#L408'>buffer-lines</a> bring-up]</span> <span id="L478" class="LineNr">478 </span> <span class="Comment"># write 'a'</span> -<span id="L479" class="LineNr">479 </span> sink <span class="Special"><-</span> write sink, <span class="Constant">97/a</span> +<span id="L479" class="LineNr">479 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>, <span class="Constant">97/a</span> <span id="L480" class="LineNr">480 </span> restart buffer-routine <span id="L481" class="LineNr">481 </span> wait-for-routine-to-block buffer-routine -<span id="L482" class="LineNr">482 </span> empty? <span class="Special"><-</span> channel-empty? buffered-chan +<span id="L482" class="LineNr">482 </span> empty? <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> buffered-chan <span id="L483" class="LineNr">483 </span> assert empty?:bool, <span class="Constant">[ </span> <span id="L484" class="LineNr">484 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after writing 'a']</span> <span id="L485" class="LineNr">485 </span> <span class="Comment"># write 'b'</span> -<span id="L486" class="LineNr">486 </span> sink <span class="Special"><-</span> write sink, <span class="Constant">98/b</span> +<span id="L486" class="LineNr">486 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>, <span class="Constant">98/b</span> <span id="L487" class="LineNr">487 </span> restart buffer-routine <span id="L488" class="LineNr">488 </span> wait-for-routine-to-block buffer-routine -<span id="L489" class="LineNr">489 </span> empty? <span class="Special"><-</span> channel-empty? buffered-chan +<span id="L489" class="LineNr">489 </span> empty? <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> buffered-chan <span id="L490" class="LineNr">490 </span> assert empty?:bool, <span class="Constant">[ </span> <span id="L491" class="LineNr">491 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after writing 'b']</span> <span id="L492" class="LineNr">492 </span> <span class="Comment"># write newline</span> -<span id="L493" class="LineNr">493 </span> sink <span class="Special"><-</span> write sink, <span class="Constant">10/newline</span> +<span id="L493" class="LineNr">493 </span> <a href='075channel.mu.html#L47'>sink</a> <span class="Special"><-</span> <a href='075channel.mu.html#L67'>write</a> <a href='075channel.mu.html#L47'>sink</a>, <span class="Constant">10/newline</span> <span id="L494" class="LineNr">494 </span> restart buffer-routine <span id="L495" class="LineNr">495 </span> wait-for-routine-to-block buffer-routine -<span id="L496" class="LineNr">496 </span> empty? <span class="Special"><-</span> channel-empty? buffered-chan +<span id="L496" class="LineNr">496 </span> empty? <span class="Special"><-</span> <a href='075channel.mu.html#L370'>channel-empty?</a> buffered-chan <span id="L497" class="LineNr">497 </span> data-emitted?:bool <span class="Special"><-</span> not empty? <span id="L498" class="LineNr">498 </span> assert data-emitted?, <span class="Constant">[ </span> <span id="L499" class="LineNr">499 </span><span class="Constant">F buffer-lines-blocks-until-newline: channel should contain data after writing newline]</span> @@ -567,17 +567,17 @@ if ('onhashchange' in window) { <span id="L504" class="LineNr">504 </span> ] <span id="L505" class="LineNr">505 </span>] <span id="L506" class="LineNr">506 </span> -<span id="L507" class="LineNr">507 </span><span class="muRecipe">def</span> drain source:&:source:char<span class="muRecipe"> -> </span>result:text, source:&:source:char [ +<span id="L507" class="LineNr">507 </span><span class="muRecipe">def</span> <a href='075channel.mu.html#L507'>drain</a> <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:char<span class="muRecipe"> -> </span>result:text, <a href='075channel.mu.html#L43'>source</a>:&:<a href='075channel.mu.html#L43'>source</a>:char [ <span id="L508" class="LineNr">508 </span> <span class="Constant">local-scope</span> <span id="L509" class="LineNr">509 </span> <span class="Constant">load-inputs</span> -<span id="L510" class="LineNr">510 </span> buf:&:buffer:char <span class="Special"><-</span> new-buffer<span class="Constant"> 30</span> +<span id="L510" class="LineNr">510 </span> buf:&:<a href='061text.mu.html#L120'>buffer</a>:char <span class="Special"><-</span> <a href='061text.mu.html#L125'>new-buffer</a><span class="Constant"> 30</span> <span id="L511" class="LineNr">511 </span> <span class="Delimiter">{</span> -<span id="L512" class="LineNr">512 </span> c:char, done?:bool <span class="Special"><-</span> read source +<span id="L512" class="LineNr">512 </span> c:char, done?:bool <span class="Special"><-</span> read <a href='075channel.mu.html#L43'>source</a> <span id="L513" class="LineNr">513 </span> <span class="muControl">break-if</span> done? <span id="L514" class="LineNr">514 </span> buf <span class="Special"><-</span> append buf, c <span id="L515" class="LineNr">515 </span> <span class="muControl"> loop</span> <span id="L516" class="LineNr">516 </span> <span class="Delimiter">}</span> -<span id="L517" class="LineNr">517 </span> result <span class="Special"><-</span> buffer-to-array buf +<span id="L517" class="LineNr">517 </span> result <span class="Special"><-</span> <a href='061text.mu.html#L338'>buffer-to-array</a> buf <span id="L518" class="LineNr">518 </span>] </pre> </body> |