@@ -137,10 +137,18 @@ module Promise : sig
137
137
138
138
ℹ️ In addition to using a promise to concurrently compute and return a
139
139
value, a cancelable promise can also represent a concurrent fiber that
140
- will continue until it is explicitly {{!try_terminate} canceled}. *)
140
+ will continue until it is explicitly {{!try_terminate} canceled}.
141
+
142
+ ⚠️ {{!try_terminate} Canceling} a promise does not immediately terminate
143
+ the fiber or wait for the fiber working to complete the promise to
144
+ terminate. Constructs like {!Bundle.join_after} and {!Flock.join_after}
145
+ only guarantee that all fibers forked within their scope have terminated
146
+ before they return or raise. The reason for this design choice in this
147
+ library is that synchronization is expensive and delaying synchronization
148
+ to the join operation is typically sufficient and amortizes the cost. *)
141
149
142
150
type !'a t
143
- (* * Represents a promise to return value of type ['a]. *)
151
+ (* * Represents a promise to produce a value of type ['a]. *)
144
152
145
153
val of_value : 'a -> 'a t
146
154
(* * [of_value value] returns a constant completed promise that returns the
@@ -155,7 +163,10 @@ module Promise : sig
155
163
the [value] that the evaluation of the promise returned, raises the
156
164
exception that the evaluation of the promise raised, or raises the
157
165
{{!Control.Terminate} [Terminate]} exception in case the promise has been
158
- canceled. *)
166
+ canceled.
167
+
168
+ ⚠️ The fiber corresponding to a {{!try_terminate} canceled} promise is not
169
+ guaranteed to have terminated at the point [await] raises. *)
159
170
160
171
val completed : 'a t -> 'a Event .t
161
172
(* * [completed promise] returns an {{!Picos_std_event.Event} event} that can
0 commit comments