-
Notifications
You must be signed in to change notification settings - Fork 0
/
thread_state.ml
31 lines (29 loc) · 1.05 KB
/
thread_state.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
type 'a thread_state =
| Return of 'a
(* [Return v] a terminated thread which has successfully
terminated with the value [v] *)
| Fail of exn
(* [Fail exn] a terminated thread which has failed with the
exception [exn]. *)
| Sleep of 'a sleeper
(* [Sleep sleeper] is a sleeping thread *)
| Repr of 'a thread_repr
(* [Repr t] a thread which behaves the same as [t] *)
and 'a thread_repr = {
mutable state : 'a thread_state;
(* The state of the thread *)
}
and 'a sleeper = {
mutable cancel : cancel;
(* How to cancel this thread. *)
mutable waiters : 'a waiter_set;
(* All thunk functions. These functions are always called inside a
enter_wakeup/leave_wakeup block. *)
mutable removed : int;
(* Number of waiter that have been disabled. When this number
reaches [max_removed], they are effectively removed from
[waiters]. *)
mutable cancel_handlers : 'a cancel_handler_set;
(* Functions to execute when this thread is canceled. Theses
functions must be executed before waiters. *)
}