summaryrefslogtreecommitdiff
path: root/lib/std/threadhooks.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-03 21:57:02 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-03 22:09:52 -0700
commit38698ba0dea7f8b8908fdd41922f4da6202a631e (patch)
treed27af0fbd7f4a83073afd00b552ce746c490812d /lib/std/threadhooks.myr
parenta986d1d8ae4c6f75384b62347c733a226edcafba (diff)
downloadmc-38698ba0dea7f8b8908fdd41922f4da6202a631e.tar.gz
Add thread hooks
I think this makes libstd thread safe.
Diffstat (limited to 'lib/std/threadhooks.myr')
-rw-r--r--lib/std/threadhooks.myr43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/std/threadhooks.myr b/lib/std/threadhooks.myr
new file mode 100644
index 0000000..71f4d4c
--- /dev/null
+++ b/lib/std/threadhooks.myr
@@ -0,0 +1,43 @@
+use "die"
+
+pkg std =
+ pkglocal var lock : (l : void# -> void)
+ pkglocal var unlock : (l : void# -> void)
+ pkglocal var memlck : void#
+ pkglocal var netlck : void#
+ pkglocal var envlck : void#
+
+ const __lockinit : ( \
+ mem : void#, \
+ net : void#, \
+ env : void#, \
+ lck : (l : void# -> void), \
+ unlck : (l : void# -> void) \
+ -> void)
+;;
+
+/* thread lock wrapper functions */
+var lock
+var unlock
+
+/* locks for various parts of libstd */
+var memlck
+var netlck
+var envlck
+/*
+work around compiler bug: we don't generate
+syms for the funcs with an initializer
+*/
+const __init__ = {
+ lock = {l; }
+ unlock = {l; }
+}
+
+const __lockinit = {mem, net, env, lck, unlck
+ memlck = mem
+ netlck = net
+ envlck = env
+ lock = lck
+ unlock = unlck
+}
+