Skip to content

Commit d75ac46

Browse files
committed
GenServer: Rename continue argument in handle_continue/2
As I was reading the docs, it was not clear what the `continue` argument was just by reading its name. handle_call and handle_cast use `request` for a similar argument, so I unified it.
1 parent 5e07218 commit d75ac46

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/elixir/lib/gen_server.ex

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ defmodule GenServer do
434434
except the process is hibernated before entering the loop. See
435435
`c:handle_call/3` for more information on hibernation.
436436
437-
Returning `{:ok, state, {:continue, continue}}` is similar to
437+
Returning `{:ok, state, {:continue, request}}` is similar to
438438
`{:ok, state}` except that immediately after entering the loop,
439439
the `c:handle_continue/2` callback will be invoked with the value
440-
`continue` as first argument.
440+
`request` as the first argument and `state` as the second one.
441441
442442
Returning `:ignore` will cause `start_link/3` to return `:ignore` and
443443
the process will exit normally without entering the loop or calling
@@ -460,7 +460,7 @@ defmodule GenServer do
460460
"""
461461
@callback init(init_arg :: term) ::
462462
{:ok, state}
463-
| {:ok, state, timeout | :hibernate | {:continue, term}}
463+
| {:ok, state, timeout | :hibernate | {:continue, request :: term}}
464464
| :ignore
465465
| {:stop, reason :: any}
466466
when state: any
@@ -487,9 +487,9 @@ defmodule GenServer do
487487
`GenServer` causes garbage collection and leaves a continuous heap that
488488
minimises the memory used by the process.
489489
490-
Returning `{:reply, reply, new_state, {:continue, continue}}` is similar to
490+
Returning `{:reply, reply, new_state, {:continue, request}}` is similar to
491491
`{:reply, reply, new_state}` except `c:handle_continue/2` will be invoked
492-
immediately after with the value `continue` as first argument.
492+
immediately after with the value `request` as the first argument and `state` as the second one.
493493
494494
Hibernating should not be used aggressively as too much time could be spent
495495
garbage collecting. Normally it should only be used when a message is not
@@ -512,7 +512,7 @@ defmodule GenServer do
512512
process exits without replying as the caller will be blocking awaiting a
513513
reply.
514514
515-
Returning `{:noreply, new_state, timeout | :hibernate | {:continue, continue}}`
515+
Returning `{:noreply, new_state, timeout | :hibernate | {:continue, request}}`
516516
is similar to `{:noreply, new_state}` except a timeout, hibernation or continue
517517
occurs as with a `:reply` tuple.
518518
@@ -528,9 +528,9 @@ defmodule GenServer do
528528
"""
529529
@callback handle_call(request :: term, from, state :: term) ::
530530
{:reply, reply, new_state}
531-
| {:reply, reply, new_state, timeout | :hibernate | {:continue, term}}
531+
| {:reply, reply, new_state, timeout | :hibernate | {:continue, request :: term}}
532532
| {:noreply, new_state}
533-
| {:noreply, new_state, timeout | :hibernate | {:continue, term}}
533+
| {:noreply, new_state, timeout | :hibernate | {:continue, request :: term}}
534534
| {:stop, reason, reply, new_state}
535535
| {:stop, reason, new_state}
536536
when reply: term, new_state: term, reason: term
@@ -551,9 +551,10 @@ defmodule GenServer do
551551
`{:noreply, new_state}` except the process is hibernated before continuing the
552552
loop. See `c:handle_call/3` for more information.
553553
554-
Returning `{:noreply, new_state, {:continue, continue}}` is similar to
554+
Returning `{:noreply, new_state, {:continue, request}}` is similar to
555555
`{:noreply, new_state}` except `c:handle_continue/2` will be invoked
556-
immediately after with the value `continue` as first argument.
556+
immediately after with the value `request` as the first argument and
557+
`state` as the second one.
557558
558559
Returning `{:stop, reason, new_state}` stops the loop and `c:terminate/2` is
559560
called with the reason `reason` and state `new_state`. The process exits with
@@ -564,7 +565,7 @@ defmodule GenServer do
564565
"""
565566
@callback handle_cast(request :: term, state :: term) ::
566567
{:noreply, new_state}
567-
| {:noreply, new_state, timeout | :hibernate | {:continue, term}}
568+
| {:noreply, new_state, timeout | :hibernate | {:continue, request :: term}}
568569
| {:stop, reason :: term, new_state}
569570
when new_state: term
570571

@@ -581,26 +582,26 @@ defmodule GenServer do
581582
"""
582583
@callback handle_info(msg :: :timeout | term, state :: term) ::
583584
{:noreply, new_state}
584-
| {:noreply, new_state, timeout | :hibernate | {:continue, term}}
585+
| {:noreply, new_state, timeout | :hibernate | {:continue, request :: term}}
585586
| {:stop, reason :: term, new_state}
586587
when new_state: term
587588

588589
@doc """
589-
Invoked to handle `continue` instructions.
590+
Invoked to handle continue request instructions.
590591
591592
It is useful for performing work after initialization or for splitting the work
592593
in a callback in multiple steps, updating the process state along the way.
593594
594595
Return values are the same as `c:handle_cast/2`.
595596
596597
This callback is optional. If one is not implemented, the server will fail
597-
if a continue instruction is used.
598+
if a continue request instruction is used.
598599
"""
599-
@callback handle_continue(continue :: term, state :: term) ::
600+
@callback handle_continue(request, state :: term) ::
600601
{:noreply, new_state}
601-
| {:noreply, new_state, timeout | :hibernate | {:continue, term}}
602+
| {:noreply, new_state, timeout | :hibernate | {:continue, request}}
602603
| {:stop, reason :: term, new_state}
603-
when new_state: term
604+
when new_state: term, request: term
604605

605606
@doc """
606607
Invoked when the server is about to exit. It should do any cleanup required.

0 commit comments

Comments
 (0)