@@ -1121,10 +1121,12 @@ defmodule GenStage do
11211121 when new_state: term , event: term
11221122
11231123 @ doc """
1124- Invoked to handle `continue` instructions.
1124+ Invoked to handle `: continue` instructions.
11251125
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.
11281130
11291131 Return values are the same as `c:handle_cast/2`.
11301132
@@ -1759,56 +1761,29 @@ defmodule GenStage do
17591761 { :producer , state } ->
17601762 init_producer ( mod , [ ] , state , nil )
17611763
1762- { :producer , state , { :continue , _term } = continue } ->
1763- init_producer ( mod , [ ] , state , continue )
1764-
1765- { :producer , state , :hibernate } ->
1766- init_producer ( mod , [ ] , state , :hibernate )
1767-
17681764 { :producer , state , opts } when is_list ( opts ) ->
17691765 init_producer ( mod , opts , state , nil )
17701766
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 )
17761769
17771770 { :producer_consumer , state } ->
17781771 init_producer_consumer ( mod , [ ] , state , nil )
17791772
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-
17861773 { :producer_consumer , state , opts } when is_list ( opts ) ->
17871774 init_producer_consumer ( mod , opts , state , nil )
17881775
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 )
17941778
17951779 { :consumer , state } ->
17961780 init_consumer ( mod , [ ] , state , nil )
17971781
1798- { :consumer , state , { :continue , _term } = continue } ->
1799- init_consumer ( mod , [ ] , state , continue )
1800-
1801- { :consumer , state , :hibernate } ->
1802- init_consumer ( mod , [ ] , state , :hibernate )
1803-
18041782 { :consumer , state , opts } when is_list ( opts ) ->
18051783 init_consumer ( mod , opts , state , nil )
18061784
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 )
18121787
18131788 { :stop , _ } = stop ->
18141789 stop
0 commit comments