Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Como concorrência funciona em Elixir?

Amanda
February 03, 2018

Como concorrência funciona em Elixir?

Amanda

February 03, 2018
Tweet

More Decks by Amanda

Other Decks in Technology

Transcript

  1. Sim

  2. {:ok, task1} = Task.async(fn -> do_some_work() end) {:ok, task2} =

    Task.async(fn -> do_more_work() end) Task.await(task1) Task.await(task2)
  3. {:ok, pid} = Agent.start_link(fn -> 0 end) value1 = Agent.get(pid,

    fn x -> x end) Agent.update(pid, fn x -> x + 1 end) value2 = Agent.get(pid, fn x -> x end)