Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / cml / core-cml / thread.sig
1 (* thread.sig
2 * 2004 Matthew Fluet (mfluet@acm.org)
3 * Ported to MLton threads.
4 *)
5
6 (* threads-sig.sml
7 *
8 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
9 * COPYRIGHT (c) 1989-1991 John H. Reppy
10 *)
11
12 signature THREAD =
13 sig
14 include THREAD_ID
15 val getTid : unit -> thread_id
16
17 val spawnc : ('a -> unit) -> 'a -> thread_id
18 val spawn : (unit -> unit) -> thread_id
19 val exit : unit -> 'a
20 val yield : unit -> unit (* mostly for benchmarking *)
21
22 val joinEvt : thread_id -> unit Event.event
23
24 (* thread-local data *)
25 val newThreadProp : (unit -> 'a) ->
26 {
27 clrFn : unit -> unit, (* clear's current thread's property *)
28 getFn : unit -> 'a, (* get current thread's property; if *)
29 (* the property is not defined, then *)
30 (* it sets it using the initialization *)
31 (* function. *)
32 peekFn : unit -> 'a option, (* return the property's value, if any *)
33 setFn : 'a -> unit (* set the property's value for the *)
34 (* current thread. *)
35 }
36 val newThreadFlag : unit -> {getFn : unit -> bool, setFn : bool -> unit}
37 end
38