@@ -1199,10 +1199,12 @@ defmodule GenStage do
11991199 when new_state: term , event: term
12001200
12011201 @ doc """
1202- Invoked to handle `continue` instructions.
1202+ Invoked to handle `: continue` instructions.
12031203
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.
12061208
12071209 Return values are the same as `c:handle_cast/2`.
12081210
@@ -1852,56 +1854,29 @@ defmodule GenStage do
18521854 { :producer , state } ->
18531855 init_producer ( mod , [ ] , state , nil )
18541856
1855- { :producer , state , { :continue , _term } = continue } ->
1856- init_producer ( mod , [ ] , state , continue )
1857-
1858- { :producer , state , :hibernate } ->
1859- init_producer ( mod , [ ] , state , :hibernate )
1860-
18611857 { :producer , state , opts } when is_list ( opts ) ->
18621858 init_producer ( mod , opts , state , nil )
18631859
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 )
18691862
18701863 { :producer_consumer , state } ->
18711864 init_producer_consumer ( mod , [ ] , state , nil )
18721865
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-
18791866 { :producer_consumer , state , opts } when is_list ( opts ) ->
18801867 init_producer_consumer ( mod , opts , state , nil )
18811868
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 )
18871871
18881872 { :consumer , state } ->
18891873 init_consumer ( mod , [ ] , state , nil )
18901874
1891- { :consumer , state , { :continue , _term } = continue } ->
1892- init_consumer ( mod , [ ] , state , continue )
1893-
1894- { :consumer , state , :hibernate } ->
1895- init_consumer ( mod , [ ] , state , :hibernate )
1896-
18971875 { :consumer , state , opts } when is_list ( opts ) ->
18981876 init_consumer ( mod , opts , state , nil )
18991877
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 )
19051880
19061881 { :stop , _ } = stop ->
19071882 stop
0 commit comments