about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-15 14:58:58 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-15 14:58:58 -0800
commitea36397b5010be4d79dcb07be5ed2b3b84217040 (patch)
treecce5cced1492a792eb814e7760ef72fa0e740080
parent44de0079e5a5a3c46370fd70af790beb886c052e (diff)
downloadmu-ea36397b5010be4d79dcb07be5ed2b3b84217040.tar.gz
267 - more intuitive channel capacity
-rw-r--r--mu.arc1
-rw-r--r--mu.arc.t10
2 files changed, 6 insertions, 5 deletions
diff --git a/mu.arc b/mu.arc
index 3bffa39f..03df9f05 100644
--- a/mu.arc
+++ b/mu.arc
@@ -853,6 +853,7 @@
 (init-fn new-channel
   ((default-scope scope-address) <- new (scope literal) (30 literal))
   ((capacity integer) <- arg)
+  ((capacity integer) <- add (capacity integer) (1 literal))  ; unused slot for full? below
   ((buffer-address tagged-value-array-address) <- new (tagged-value-array literal) (capacity integer))
   ((result channel-address) <- new (channel literal))
   ((full integer-address) <- get-address (result channel-address deref) (first-full offset))
diff --git a/mu.arc.t b/mu.arc.t
index 04d3ffbe..460465ed 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -1890,8 +1890,8 @@
 (new-trace "channel-write-wrap")
 (add-fns
   '((main
-      ; channel with 2 slots (capacity 1 since we waste a slot)
-      ((1 channel-address) <- new-channel (2 literal))
+      ; channel with 1 slot
+      ((1 channel-address) <- new-channel (1 literal))
       ; write a value
       ((2 integer-address) <- new (integer literal))
       ((2 integer-address deref) <- copy (34 literal))
@@ -1916,8 +1916,8 @@
 (new-trace "channel-read-wrap")
 (add-fns
   '((main
-      ; channel with 2 slots (capacity 1 since we waste a slot)
-      ((1 channel-address) <- new-channel (2 literal))
+      ; channel with 1 slot
+      ((1 channel-address) <- new-channel (1 literal))
       ; write a value
       ((2 integer-address) <- new (integer literal))
       ((2 integer-address deref) <- copy (34 literal))
@@ -1976,7 +1976,7 @@
 (new-trace "channel-write-full")
 (add-fns
   '((main
-      ((1 channel-address) <- new-channel (2 literal))
+      ((1 channel-address) <- new-channel (1 literal))
       ((2 integer-address) <- new (integer literal))
       ((2 integer-address deref) <- copy (34 literal))
       ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address))