Skip to content

Instantly share code, notes, and snippets.

@khionu
Created September 2, 2021 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khionu/7da26e1c53108ee4b462ef570f19b61b to your computer and use it in GitHub Desktop.
Save khionu/7da26e1c53108ee4b462ef570f19b61b to your computer and use it in GitHub Desktop.
reply_after
def handle_call(msg, from, state) do
delay = delay_calc(state)
GenServer.reply_after(from, :go, delay)
{:no_reply, state}
end
def handle_call(msg, from, state) do
delay = delay_calc(state)
Task.start(fn ->
sleep(delay)
GenServer.reply(from, :go)
end)
{:no_reply, state}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment