@@ -10,12 +10,12 @@ module type Trigger = sig
10
10
11
11
Typically the scheduler calls {{!Fiber.try_suspend} [try_suspend]}, which
12
12
in turn calls {!on_signal}, to attach a scheduler specific [resume] action
13
- to the [trigger]. The scheduler must guarantee that the fiber will be
13
+ to the [trigger]. The scheduler must guarantee that the fiber will be
14
14
resumed after {!signal} has been called on the [trigger].
15
15
16
16
Whether being resumed due to cancelation or not, the trigger must be
17
- either {{!signal} signaled} outside of the effect handler, or {{!dispose}
18
- disposed} by the effect handler, before resuming the fiber.
17
+ either {{!signal} signaled} outside of the effect handler, or
18
+ {{!dispose} disposed} by the effect handler, before resuming the fiber.
19
19
20
20
In case the fiber permits propagation of cancelation and the computation
21
21
associated with the fiber has been canceled the scheduler is free to
@@ -37,9 +37,9 @@ module type Computation = sig
37
37
(* * Schedulers must handle the {!Cancel_after} effect to implement the
38
38
behavior of {!cancel_after}.
39
39
40
- The scheduler should typically {{!try_attach} attach} a {{!Trigger}
41
- trigger} to the computation passed with the effect and arrange the
42
- timeout to be canceled upon signal to avoid space leaks.
40
+ The scheduler should typically {{!try_attach} attach} a
41
+ {{!Trigger} trigger} to the computation passed with the effect and arrange
42
+ the timeout to be canceled upon signal to avoid space leaks.
43
43
44
44
The scheduler should measure time using a monotonic clock.
45
45
@@ -80,15 +80,15 @@ module type Fiber = sig
80
80
('b , 'r ) Effect.Shallow .handler ->
81
81
'r
82
82
(* * [resume_with fiber k h] is equivalent to
83
- {{!Fiber.canceled} [Effect.Shallow.continue_with k (Fiber.canceled t) h]}. *)
83
+ {{!Fiber.canceled} [Effect.Shallow.continue_with k (Fiber.canceled t) h]}.
84
+ *)
84
85
85
86
val continue : t -> ('v , 'r ) Effect.Deep .continuation -> 'v -> 'r
86
87
(* * [continue fiber k v] is equivalent to:
87
88
{[
88
89
match Fiber.canceled fiber with
89
90
| None -> Effect.Deep.continue k v
90
- | Some (exn, bt) ->
91
- Effect.Deep.discontinue_with_backtrace k exn bt
91
+ | Some (exn, bt) -> Effect.Deep.discontinue_with_backtrace k exn bt
92
92
]} *)
93
93
94
94
val continue_with :
@@ -101,20 +101,19 @@ module type Fiber = sig
101
101
{[
102
102
match Fiber.canceled fiber with
103
103
| None -> Effect.Shallow.continue_with k v h
104
- | Some (exn, bt) ->
105
- Effect.Shallow.discontinue_with_backtrace k exn bt h
104
+ | Some (exn, bt) -> Effect.Shallow.discontinue_with_backtrace k exn bt h
106
105
]} *)
107
106
108
107
(* * Schedulers must handle the {!Current} effect to implement the behavior of
109
108
{!current}.
110
109
111
110
⚠️ The scheduler must eventually resume the fiber without propagating
112
- cancelation. This is necessary to allow a fiber to control the
113
- propagation of cancelation through the {{!t} fiber}.
111
+ cancelation. This is necessary to allow a fiber to control the propagation
112
+ of cancelation through the {{!t} fiber}.
114
113
115
- The scheduler is free to choose which ready fiber to resume next.
116
- However, in typical use cases of {!current} it makes sense to give
117
- priority to the fiber performing {!Current}, but this is not required. *)
114
+ The scheduler is free to choose which ready fiber to resume next. However,
115
+ in typical use cases of {!current} it makes sense to give priority to the
116
+ fiber performing {!Current}, but this is not required. *)
118
117
type _ Effect.t + = private Current : t Effect .t
119
118
120
119
(* * Schedulers must handle the {!Yield} effect to implement the behavior of
@@ -125,7 +124,7 @@ module type Fiber = sig
125
124
discontinue the fiber immediately.
126
125
127
126
The scheduler should give priority to running other ready fibers before
128
- resuming the fiber performing {!Yield}. A scheduler that always
127
+ resuming the fiber performing {!Yield}. A scheduler that always
129
128
immediately resumes the fiber performing {!Yield} may prevent an otherwise
130
129
valid program from making progress. *)
131
130
type _ Effect.t + = private Yield : unit Effect .t
@@ -139,7 +138,7 @@ module type Fiber = sig
139
138
⚠️ In case the fiber performing {!Spawn} permits propagation of cancelation
140
139
and the computation associated with the fiber has been canceled before it
141
140
performed {!Spawn}, the scheduler should discontinue the current fiber and
142
- not spawn a new fiber. If cancelation happens during the handling of
141
+ not spawn a new fiber. If cancelation happens during the handling of
143
142
{!Spawn} the scheduler is free to either spawn a new fiber, in which case
144
143
the current fiber must be continued normally, or not spawn a fiber, in
145
144
which case the current fiber must be discontinued, i.e. {!spawn} raises an
@@ -151,9 +150,9 @@ module type Fiber = sig
151
150
called.
152
151
153
152
In other words, spawn should (effectively) check cancelation at least once
154
- and be all or nothing. Furthermore, in case a newly spawned fiber is
153
+ and be all or nothing. Furthermore, in case a newly spawned fiber is
155
154
canceled before its [main] is called, the scheduler must still call the
156
- [main]. This allows a program to ensure, i.e. keep track of, that all
155
+ [main]. This allows a program to ensure, i.e. keep track of, that all
157
156
fibers it spawns are terminated properly and any resources transmitted to
158
157
spawned fibers will be disposed properly. *)
159
158
type _ Effect.t + =
0 commit comments