@@ -1199,10 +1199,12 @@ defmodule GenStage do
1199
1199
when new_state: term , event: term
1200
1200
1201
1201
@ doc """
1202
- Invoked to handle `continue` instructions.
1202
+ Invoked to handle `: continue` instructions.
1203
1203
1204
- It is useful for performing work after initialization or for splitting the work
1205
- in a callback in multiple steps, updating the process state along the way.
1204
+ This callback can be used to perform work right after emitting events from
1205
+ other callbacks. The "continue mechanism" makes sure that no messages,
1206
+ calls, casts, or anything else will be handled between a callback emitting
1207
+ a `:continue` tuple and the `c:handle_continue/2` callback being invoked.
1206
1208
1207
1209
Return values are the same as `c:handle_cast/2`.
1208
1210
@@ -1852,56 +1854,29 @@ defmodule GenStage do
1852
1854
{ :producer , state } ->
1853
1855
init_producer ( mod , [ ] , state , nil )
1854
1856
1855
- { :producer , state , { :continue , _term } = continue } ->
1856
- init_producer ( mod , [ ] , state , continue )
1857
-
1858
- { :producer , state , :hibernate } ->
1859
- init_producer ( mod , [ ] , state , :hibernate )
1860
-
1861
1857
{ :producer , state , opts } when is_list ( opts ) ->
1862
1858
init_producer ( mod , opts , state , nil )
1863
1859
1864
- { :producer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1865
- init_producer ( mod , opts , state , continue )
1866
-
1867
- { :producer , state , :hibernate , opts } when is_list ( opts ) ->
1868
- init_producer ( mod , opts , state , :hibernate )
1860
+ { :producer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1861
+ init_producer ( mod , opts , state , continue_or_hibernate )
1869
1862
1870
1863
{ :producer_consumer , state } ->
1871
1864
init_producer_consumer ( mod , [ ] , state , nil )
1872
1865
1873
- { :producer_consumer , state , { :continue , _term } = continue } ->
1874
- init_producer_consumer ( mod , [ ] , state , continue )
1875
-
1876
- { :producer_consumer , state , :hibernate } ->
1877
- init_producer_consumer ( mod , [ ] , state , :hibernate )
1878
-
1879
1866
{ :producer_consumer , state , opts } when is_list ( opts ) ->
1880
1867
init_producer_consumer ( mod , opts , state , nil )
1881
1868
1882
- { :producer_consumer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1883
- init_producer_consumer ( mod , opts , state , continue )
1884
-
1885
- { :producer_consumer , state , :hibernate , opts } when is_list ( opts ) ->
1886
- init_producer_consumer ( mod , opts , state , :hibernate )
1869
+ { :producer_consumer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1870
+ init_producer_consumer ( mod , opts , state , continue_or_hibernate )
1887
1871
1888
1872
{ :consumer , state } ->
1889
1873
init_consumer ( mod , [ ] , state , nil )
1890
1874
1891
- { :consumer , state , { :continue , _term } = continue } ->
1892
- init_consumer ( mod , [ ] , state , continue )
1893
-
1894
- { :consumer , state , :hibernate } ->
1895
- init_consumer ( mod , [ ] , state , :hibernate )
1896
-
1897
1875
{ :consumer , state , opts } when is_list ( opts ) ->
1898
1876
init_consumer ( mod , opts , state , nil )
1899
1877
1900
- { :consumer , state , { :continue , _term } = continue , opts } when is_list ( opts ) ->
1901
- init_consumer ( mod , opts , state , continue )
1902
-
1903
- { :consumer , state , :hibernate , opts } when is_list ( opts ) ->
1904
- init_consumer ( mod , opts , state , :hibernate )
1878
+ { :consumer , state , opts , continue_or_hibernate } when is_list ( opts ) ->
1879
+ init_consumer ( mod , opts , state , continue_or_hibernate )
1905
1880
1906
1881
{ :stop , _ } = stop ->
1907
1882
stop
0 commit comments