@@ -1411,13 +1411,25 @@ defmodule GenStage do
1411
1411
@ doc """
1412
1412
Cancels the given subscription on the producer.
1413
1413
1414
- Once the producer receives the request, a confirmation
1415
- may be forwarded to the consumer (although there is no
1416
- guarantee as the producer may crash for unrelated reasons
1417
- before). This is an asynchronous request.
1418
-
1419
- It accepts the same options as `Process.send/3`, and returns the same value as
1420
- `Process.send/3`.
1414
+ The second argument is the cancellation reason. Once the
1415
+ producer receives the request, a confirmation may be
1416
+ forwarded to the consumer (although there is no guarantee
1417
+ as the producer may crash for unrelated reasons before).
1418
+ The consumer will react to the cancellation according to
1419
+ the `:cancel` option given when subscribing. For example:
1420
+
1421
+ GenStage.cancel({pid, subscription}, :shutdown)
1422
+
1423
+ will cause the consumer to crash if the `:cancel` given
1424
+ when subscribing is `:permanent` (the default) but it
1425
+ won't cause a crash in other modes. See the options in
1426
+ `sync_subscribe/3` for more information.
1427
+
1428
+ The `cancel` operation is an asynchronous request. The
1429
+ third argument are same options as `Process.send/3`,
1430
+ allowing you to pass `:noconnect` or `:nosuspend` which
1431
+ is useful when working across nodes. This function returns
1432
+ the same value as `Process.send/3`.
1421
1433
"""
1422
1434
@ spec cancel ( from , term , [ :noconnect | :nosuspend ] ) :: :ok | :noconnect | :nosuspend
1423
1435
def cancel ( { pid , ref } = _producer_subscription , reason , opts \\ [ ] ) do
0 commit comments