diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-28 20:08:04 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-28 20:08:04 -0700 |
commit | 6c69569a4c4ca3a23635d4d7a40f0fe557194619 (patch) | |
tree | 162ab23faa9fdc402732f35b875b8755bb646b33 /html/075channel.mu.html | |
parent | 6f65d5918f4b73de56e6cb6362c7cbc7dbbe5945 (diff) | |
download | mu-6c69569a4c4ca3a23635d4d7a40f0fe557194619.tar.gz |
3430
Diffstat (limited to 'html/075channel.mu.html')
-rw-r--r-- | html/075channel.mu.html | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/html/075channel.mu.html b/html/075channel.mu.html index a2b049a6..e02135ef 100644 --- a/html/075channel.mu.html +++ b/html/075channel.mu.html @@ -83,15 +83,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-channel capacity:num<span class="muRecipe"> -> </span>in:&:source:_elem, out:&:sink:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:&:channel:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(channel _elem): type<span class="Delimiter">}</span> + result:&:channel:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(channel _elem): <span class="muData">type</span><span class="Delimiter">}</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">first-full:offset</span>, <span class="Constant">0</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">first-free:offset</span>, <span class="Constant">0</span> capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="Comment"># unused slot for 'full?' below</span> data:&:@:_elem<span class="Special"> <- </span>new <span class="Constant">_elem:type</span>, capacity *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, data - in<span class="Special"> <- </span>new <span class="Delimiter">{</span>(source _elem): type<span class="Delimiter">}</span> + in<span class="Special"> <- </span>new <span class="Delimiter">{</span>(source _elem): <span class="muData">type</span><span class="Delimiter">}</span> *in<span class="Special"> <- </span>put *in, <span class="Constant">chan:offset</span>, result - out<span class="Special"> <- </span>new <span class="Delimiter">{</span>(sink _elem): type<span class="Delimiter">}</span> + out<span class="Special"> <- </span>new <span class="Delimiter">{</span>(sink _elem): <span class="muData">type</span><span class="Delimiter">}</span> *out<span class="Special"> <- </span>put *out, <span class="Constant">chan:offset</span>, result ] @@ -213,9 +213,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-increments-free [ + <span class="Constant">local-scope</span> + _, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> run [ - <span class="Constant">local-scope</span> - _, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> chan:&:channel:num<span class="Special"> <- </span>get *sink, <span class="Constant">chan:offset</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-full:offset</span> @@ -228,10 +228,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-read-increments-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> _, _, source<span class="Special"> <- </span>read source chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-full:offset</span> @@ -244,14 +244,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-wrap [ + <span class="Constant">local-scope</span> + <span class="Comment"># channel with just 1 slot</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> + <span class="Comment"># write and read a value</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> + _, _, source<span class="Special"> <- </span>read source run [ - <span class="Constant">local-scope</span> - <span class="Comment"># channel with just 1 slot</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> - <span class="Comment"># write and read a value</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> - _, _, source<span class="Special"> <- </span>read source <span class="Comment"># first-free will now be 1</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-free:offset</span> <span class="Constant">11</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-free:offset</span> @@ -285,9 +285,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-not-empty [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> run [ - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan @@ -299,10 +300,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan @@ -314,11 +315,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-read-not-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> _, _, source<span class="Special"> <- </span>read source <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan |