shithub: mc

Download patch

ref: 920e16ca93f648b551af2b688de6a1d5fe1cb802
parent: ee8cd40d871ece1bf971f60308c7c007df391bca
author: Ori Bernstein <ori@eigenstate.org>
date: Thu May 5 21:55:15 EDT 2016

Remove unbaked APIs, fix syntax a bit.

--- a/lib/thread/bld.proj
+++ b/lib/thread/bld.proj
@@ -3,7 +3,6 @@
 
 	# linux impl of basic thread primitives
 	condvar+linux.myr
-	future+linux.myr
 	mutex+linux.myr
 	spawn+linux.myr
 	exit+linux-x64.s
--- a/lib/thread/future+linux.myr
+++ /dev/null
@@ -1,48 +1,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
-}
--- a/lib/thread/mutex+linux.myr
+++ b/lib/thread/mutex+linux.myr
@@ -35,7 +35,7 @@
 	for var i = 0; i < nspin; i++
 		c = xcas(&mtx._state, Unlocked, Locked) 
 		if c == Unlocked
-			->
+			-> void
 		;;
 	;;
 
@@ -67,7 +67,7 @@
 	if mtx._state == Contended
 		mtx._state = Unlocked
 	elif xchg(&mtx._state, Unlocked) == Locked
-		->
+		-> void
 	;;
 
 	/* wake one thread */