summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-06 01:55:15 -0400
committerOri Bernstein <ori@eigenstate.org>2016-05-06 01:55:15 -0400
commit920e16ca93f648b551af2b688de6a1d5fe1cb802 (patch)
tree93f413800e324e76fd205a48b182b1aec05deaaf /lib/thread
parentee8cd40d871ece1bf971f60308c7c007df391bca (diff)
downloadmc-920e16ca93f648b551af2b688de6a1d5fe1cb802.tar.gz
Remove unbaked APIs, fix syntax a bit.
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/bld.proj1
-rw-r--r--lib/thread/future+linux.myr48
-rw-r--r--lib/thread/mutex+linux.myr4
3 files changed, 2 insertions, 51 deletions
diff --git a/lib/thread/bld.proj b/lib/thread/bld.proj
index cb7061d..ccb1a56 100644
--- a/lib/thread/bld.proj
+++ b/lib/thread/bld.proj
@@ -3,7 +3,6 @@ lib thread =
# linux impl of basic thread primitives
condvar+linux.myr
- future+linux.myr
mutex+linux.myr
spawn+linux.myr
exit+linux-x64.s
diff --git a/lib/thread/future+linux.myr b/lib/thread/future+linux.myr
deleted file mode 100644
index 1977026..0000000
--- a/lib/thread/future+linux.myr
+++ /dev/null
@@ -1,48 +0,0 @@
-use std
-use sys
-
-use "atomic.use"
-use "common.use"
-
-pkg thread =
- type future(@a) = struct
- _state : int32
- _val : @a
- ;;
-
- generic mkfut : (-> future(@a))
- generic futset : (fut : future(@a)#, val : @a -> bool)
- generic futget : (fut : future(@a)# -> @a)
- generic futtryget : (fut : future(@a)# -> std.option(@a))
-;;
-
-const Clear = 0
-const Setting = 1
-const Set = 2
-
-generic mkfut = {
- -> [._state = Clear ]
-}
-
-generic futset = {fut, val
- /* If we don't get a clear, we failed to set the value */
- if xcas(&fut._state, Clear, Setting) != Clear
- -> false
- ;;
- fut._val = val
- fut._state = Set
- sys.futex(&fut._state, sys.Futexwake | sys.Futexpriv, 0x7fffffff, Zptr, Zptr, 0)
- -> true
-}
-
-generic futget = {fut
- var st
-
- /* we can transition from Set to Setting. */
- st = fut._state
- while st != Set
- sys.futex(&fut._state, sys.Futexwait | sys.Futexpriv, st, Zptr, Zptr, 0)
- st = fut._state
- ;;
- -> fut._val
-}
diff --git a/lib/thread/mutex+linux.myr b/lib/thread/mutex+linux.myr
index 3ce6d2a..37bec62 100644
--- a/lib/thread/mutex+linux.myr
+++ b/lib/thread/mutex+linux.myr
@@ -35,7 +35,7 @@ const mtxlock = {mtx
for var i = 0; i < nspin; i++
c = xcas(&mtx._state, Unlocked, Locked)
if c == Unlocked
- ->
+ -> void
;;
;;
@@ -67,7 +67,7 @@ const mtxunlock = {mtx
if mtx._state == Contended
mtx._state = Unlocked
elif xchg(&mtx._state, Unlocked) == Locked
- ->
+ -> void
;;
/* wake one thread */