Last active
February 5, 2020 06:46
-
-
Save iantbutler01/28a8fb16c49289eee0c8887274051e39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_info(:schedule_work, state) do | |
unless :queue.is_empty(state) do | |
for _ <- 0..System.schedulers_online() do | |
Task.Supervisor.async_nolink(CrawlerExample.WorkerSupervisor, fn -> | |
CrawlerExample.Worker.work(@depth_limit) | |
end) | |
end | |
end | |
schedule_work(@work_interval) | |
{:noreply, state} | |
end | |
def handle_info({_, :ok}, state), do: {:noreply, state} | |
def handle_info({:DOWN, _, :process, _pid, _exception}, state), do: {:noreply, state} | |
defp schedule_work(interval), do: :erlang.send_after(interval, self(), :schedule_work) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment