From 26ea29a30daa2929ae50b477e29db10a385a7d4f Mon Sep 17 00:00:00 2001 From: Tim Chambers Date: Fri, 19 Apr 2024 11:37:47 -0700 Subject: [PATCH 1/2] Correct task remote vs. local documentation The listed examples had the headings reversed. This is a documentation only change. --- lib/elixir/lib/task.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elixir/lib/task.ex b/lib/elixir/lib/task.ex index 4ff6863c3b4..03a8ffca0f5 100644 --- a/lib/elixir/lib/task.ex +++ b/lib/elixir/lib/task.ex @@ -135,10 +135,10 @@ defmodule Task do With `Task.Supervisor`, it is easy to dynamically start tasks across nodes: - # On the remote node named :remote@local + # On the client Task.Supervisor.start_link(name: MyApp.DistSupervisor) - # On the client + # On the remote node named :remote@local supervisor = {MyApp.DistSupervisor, :remote@local} Task.Supervisor.async(supervisor, MyMod, :my_fun, [arg1, arg2, arg3]) From 7c6800a211bd73db8ce9dc8953ad2e71d16bbc50 Mon Sep 17 00:00:00 2001 From: Tim Chambers Date: Sun, 21 Apr 2024 12:34:52 -0700 Subject: [PATCH 2/2] Indicate distributed task execution as two step process Avoid interpretation of this as 2 indidependent steps, but rather a two-step process setting up the remote clients readiness and then making the appropriate local calls to initiate the task. --- lib/elixir/lib/task.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/elixir/lib/task.ex b/lib/elixir/lib/task.ex index 03a8ffca0f5..a63218157ca 100644 --- a/lib/elixir/lib/task.ex +++ b/lib/elixir/lib/task.ex @@ -135,14 +135,14 @@ defmodule Task do With `Task.Supervisor`, it is easy to dynamically start tasks across nodes: - # On the client + # First on the remote node named :remote@local Task.Supervisor.start_link(name: MyApp.DistSupervisor) - # On the remote node named :remote@local + # Then on the local client node supervisor = {MyApp.DistSupervisor, :remote@local} Task.Supervisor.async(supervisor, MyMod, :my_fun, [arg1, arg2, arg3]) - Note that, when working with distributed tasks, one should use the + Note that, as above, when working with distributed tasks, one should use the `Task.Supervisor.async/5` function that expects explicit module, function, and arguments, instead of `Task.Supervisor.async/3` that works with anonymous functions. That's because anonymous functions expect the same module version