Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Last active October 24, 2017 17:50
Show Gist options
  • Save shahryarjb/36f01b8d869d8f14c947640f45fd2bb8 to your computer and use it in GitHub Desktop.
Save shahryarjb/36f01b8d869d8f14c947640f45fd2bb8 to your computer and use it in GitHub Desktop.
defmodule Tasksups.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
# use Supervisor
def start(_type, _args) do
import Supervisor.Spec, warn: false
# List all child processes to be supervised
children = [
# Starts a worker by calling: Tasksups.Worker.start_link(arg)
# {Tasksups.Worker, arg},
supervisor(Task.Supervisor, [[name: Tasksups.TaskSupervisor, restart: :transient]]),
supervisor(Task.Supervisor, [[name: Tasksups.ConflyggsTaskSupervisor, restart: :transient]])
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Tasksups.Supervisor]
Supervisor.start_link(children, opts)
end
end
defmodule Tasksups.Conflyggs do
def hello do
Task.Supervisor.async_nolink Tasksups.ConflyggsTaskSupervisor, fn ->
:timer.sleep(10000)
IO.puts "hi Shahryar tavakkoli"
end
end
def by do
Task.Supervisor.async_nolink Tasksups.ConflyggsTaskSupervisor, fn ->
:timer.sleep(10000)
IO.puts "by Shahryar tavakkoli"
end
end
end
defmodule Tasksups do
def hello do
Task.Supervisor.async_nolink Tasksups.TaskSupervisor, fn ->
:timer.sleep(10000)
IO.puts "hi Shahryar tavakkoli"
end
end
def by do
Task.Supervisor.async_nolink Tasksups.TaskSupervisor, fn ->
:timer.sleep(10000)
IO.puts "by Shahryar tavakkoli"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment