@@ -133,22 +133,29 @@ module type Fiber = sig
133
133
(* * Schedulers must handle the {!Spawn} effect to implement the behavior of
134
134
{!spawn}.
135
135
136
- In case the fiber permits propagation of cancelation and the computation
137
- associated with the fiber has been canceled the scheduler is free to
138
- discontinue the fiber immediately before spawning new fibers.
139
-
140
- The scheduler is free to run the newly created fiber on any domain and
141
- decide which fiber to give priority to.
142
-
143
- ⚠️ The scheduler should guarantee that, when [Spawn] returns normally, the
144
- given [main] will eventually be called by the scheduler and, when [Spawn]
145
- raises an exception, the [main] will not be called. In other words,
146
- [Spawn] should check cancelation just once and be all or nothing.
147
- Furthermore, in case a newly spawned fiber is canceled before its main is
148
- called, the scheduler must still call the main. This allows a program to
149
- ensure, i.e. keep track of, that all fibers it spawns are terminated
150
- properly and any resources transmitted to spawned fibers will be disposed
151
- properly. *)
136
+ The scheduler is free to run the newly created fiber on any domain or
137
+ thread and decide which fiber to give priority to.
138
+
139
+ ⚠️ In case the fiber performing {!Spawn} permits propagation of cancelation
140
+ and the computation associated with the fiber has been canceled before it
141
+ performed {!Spawn}, the scheduler should discontinue the current fiber and
142
+ not spawn a new fiber. If cancelation happens during the handling of
143
+ {!Spawn} the scheduler is free to either spawn a new fiber, in which case
144
+ the current fiber must be continued normally, or not spawn a fiber, in
145
+ which case the current fibers must be discontinued, i.e. {!spawn} raises
146
+ an exception.
147
+
148
+ ⚠️ The scheduler should guarantee that, when the {!Spawn} handler continues
149
+ the fiber normally, the given [main] will eventually be called by the
150
+ scheduler and, when spawn discontinues the fiber, the [main] will not be
151
+ called.
152
+
153
+ 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
155
+ 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
157
+ fibers it spawns are terminated properly and any resources transmitted to
158
+ spawned fibers will be disposed properly. *)
152
159
type _ Effect.t + =
153
160
private
154
161
| Spawn : { fiber : t ; main : t -> unit } -> unit Effect .t
0 commit comments