@@ -1121,10 +1121,12 @@ defmodule GenStage do
1121
1121
when new_state: term , event: term
1122
1122
1123
1123
@ doc """
1124
- Invoked to handle `continue` instructions.
1124
+ Invoked to handle `: continue` instructions.
1125
1125
1126
- It is useful for performing work after initialization or for splitting the work
1127
- in a callback in multiple steps, updating the process state along the way.
1126
+ This callback can be used to perform work right after emitting events from
1127
+ other callbacks. The "continue mechanism" makes sure that no messages,
1128
+ calls, casts, or anything else will be handled between a callback emitting
1129
+ a `:continue` tuple and the `c:handle_continue/2` callback being invoked.
1128
1130
1129
1131
Return values are the same as `c:handle_cast/2`.
1130
1132
@@ -1759,56 +1761,29 @@ defmodule GenStage do
1759
1761
{ :producer , state } ->
1760
1762
init_producer ( mod , [ ] , state , nil )
1761
1763
1762
- { :producer , state , { :continue , _term } = continue } ->
1763
- init_producer ( mod , [ ] , state , continue )
1764
-
1765
- { :producer , state , :hibernate } ->
1766
- init_producer ( mod , [ ] , state , :hibernate )
1767
-
1768
1764
{ :producer , state , opts } when is_list ( opts ) ->
1769
1765
init_producer ( mod , opts , state , nil )
1770
1766
1771
- { :producer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1772
- init_producer ( mod , opts , state , continue )
1773
-
1774
- { :producer , state , :hibernate , opts } when is_list ( opts ) ->
1775
- init_producer ( mod , opts , state , :hibernate )
1767
+ { :producer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1768
+ init_producer ( mod , opts , state , continue_or_hibernate )
1776
1769
1777
1770
{ :producer_consumer , state } ->
1778
1771
init_producer_consumer ( mod , [ ] , state , nil )
1779
1772
1780
- { :producer_consumer , state , { :continue , _term } = continue } ->
1781
- init_producer_consumer ( mod , [ ] , state , continue )
1782
-
1783
- { :producer_consumer , state , :hibernate } ->
1784
- init_producer_consumer ( mod , [ ] , state , :hibernate )
1785
-
1786
1773
{ :producer_consumer , state , opts } when is_list ( opts ) ->
1787
1774
init_producer_consumer ( mod , opts , state , nil )
1788
1775
1789
- { :producer_consumer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1790
- init_producer_consumer ( mod , opts , state , continue )
1791
-
1792
- { :producer_consumer , state , :hibernate , opts } when is_list ( opts ) ->
1793
- init_producer_consumer ( mod , opts , state , :hibernate )
1776
+ { :producer_consumer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1777
+ init_producer_consumer ( mod , opts , state , continue_or_hibernate )
1794
1778
1795
1779
{ :consumer , state } ->
1796
1780
init_consumer ( mod , [ ] , state , nil )
1797
1781
1798
- { :consumer , state , { :continue , _term } = continue } ->
1799
- init_consumer ( mod , [ ] , state , continue )
1800
-
1801
- { :consumer , state , :hibernate } ->
1802
- init_consumer ( mod , [ ] , state , :hibernate )
1803
-
1804
1782
{ :consumer , state , opts } when is_list ( opts ) ->
1805
1783
init_consumer ( mod , opts , state , nil )
1806
1784
1807
- { :consumer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1808
- init_consumer ( mod , opts , state , continue )
1809
-
1810
- { :consumer , state , :hibernate , opts } when is_list ( opts ) ->
1811
- init_consumer ( mod , opts , state , :hibernate )
1785
+ { :consumer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1786
+ init_consumer ( mod , opts , state , continue_or_hibernate )
1812
1787
1813
1788
{ :stop , _ } = stop ->
1814
1789
stop
0 commit comments