about summary refs log tree commit diff stats
path: root/075channel.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-05-12 10:22:26 -0700
committerKartik Agaram <vc@akkartik.com>2018-05-12 10:22:26 -0700
commitcdf2822743b3beeb37ebc3deea8e08b6130698c5 (patch)
treeb7946314d79e8df95eb16703b65832e20f7ee620 /075channel.mu
parentbd222553d7bc7d91d3eebae5639b01f58c8f7c75 (diff)
downloadmu-cdf2822743b3beeb37ebc3deea8e08b6130698c5.tar.gz
4242 - get rid of refcounts entirely
We're going to lean back into the experiment of commit 4179 back in Jan.
If we delete memory it's up to us to ensure no pointers into it survive.

Since deep-copy depends on our refcounting infrastructure, it's gone as
well. So we're going to have to start watching out for pointers shared
over channels.
Diffstat (limited to '075channel.mu')
-rw-r--r--075channel.mu18
1 files changed, 5 insertions, 13 deletions
diff --git a/075channel.mu b/075channel.mu
index 1f8248ef..422b2ab8 100644
--- a/075channel.mu
+++ b/075channel.mu
@@ -1,18 +1,11 @@
 # Mu synchronizes between routines using channels rather than locks, like
 # Erlang and Go.
 #
-# Key properties of channels:
+# The key property of channels: Writing to a full channel or reading from an
+# empty one will put the current routine in 'waiting' state until the
+# operation can be completed.
 #
-#   a) Writing to a full channel or reading from an empty one will put the
-#   current routine in 'waiting' state until the operation can be completed.
-#
-#   b) Writing to a channel implicitly performs a deep copy. This prevents
-#   addresses from being shared between routines, and therefore eliminates all
-#   possibility of race conditions.
-#
-# There's still a narrow window for race conditions: the inputs passed in
-# to 'start-running'. Pass only channels into routines and you should be fine.
-# Any other mutable inputs will require locks.
+# Beware of addresses passed into channels. They can cause race conditions.
 
 scenario channel [
   run [
@@ -92,8 +85,7 @@ def write out:&:sink:_elem, val:_elem -> out:&:sink:_elem [
   # store a deep copy of val
   circular-buffer:&:@:_elem <- get *chan, data:offset
   free:num <- get *chan, first-free:offset
-  val-copy:_elem <- deep-copy val  # on this instruction rests all Mu's concurrency-safety
-  *circular-buffer <- put-index *circular-buffer, free, val-copy
+  *circular-buffer <- put-index *circular-buffer, free, val
   # mark its slot as filled
   free <- add free, 1
   {