1 (* Copyright (C) 2004-2008 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
10 signature MLTON_THREAD =
12 structure AtomicState :
14 datatype t = NonAtomic | Atomic of int
16 val atomically: (unit -> 'a) -> 'a
17 val atomicBegin: unit -> unit
18 val atomicEnd: unit -> unit
19 val atomicState: unit -> AtomicState.t
29 * as switch, but assumes an atomic calling context. Upon
30 * switch-ing back to the current thread, an implicit atomicEnd is
33 val atomicSwitch: ('a t -> Runnable.t) -> 'a
35 * create a new thread that, when run, applies f to
36 * the value given to the thread. f must terminate by
37 * switch-ing to another thread or exiting the process.
39 val new: ('a -> unit) -> 'a t
41 * create a new thread (destroying t in the process) that first
42 * applies f to the value given to the thread and then continues
43 * with t. This is a constant time operation.
45 val prepend: 'a t * ('b -> 'a) -> 'b t
47 * create a new runnable thread (destroying t in the process)
48 * that will evaluate t on v.
50 val prepare: 'a t * 'a -> Runnable.t
52 * apply f to the current thread to get rt, and then start
53 * running thread rt. It is an error for f to
54 * perform another switch. f is guaranteed to run
57 val switch: ('a t -> Runnable.t) -> 'a
60 signature MLTON_THREAD_EXTRA =
64 val amInSignalHandler: unit -> bool
65 val register: int * (MLtonPointer.t -> unit) -> unit
66 val setSignalHandler: (Runnable.t -> Runnable.t) -> unit
67 val switchToSignalHandler: unit -> unit