-
Notifications
You must be signed in to change notification settings - Fork 4
Are Tasks Connectable? #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Tasks can be connectable if we define a task as follows:
The current tasks fit into this idea where #2 is specified (or implied) at launch. The alternative is to launch the task without #2 specified and upon completion the task will wait for connection to a receiving process. |
Tasks can also be connectable if we make them follow the same message pattern (probably the |
Would we allow changing the target of an already launched task? That's what being connectable means to me: event = GenEvent.start_link
stream = GenEvent.stream(event)
spawn_link fn ->
stream |> Enum.each &IO.puts/1
end
...
task = Task.async( fn -> "hi" end )
Connectable.connect(task, event) Should result in "hi" being printed to the screen. |
Ah, I see what you mean. That would be tricky as the task would likely be already done and sent to the caller. We could change how tasks work but that would increase their overhead. Interesting enough, I was thinking the connectable protocol was always about connecting to self (self would always be the second argument). GenEvent is just more flexible. |
We could have the Task process block until connected. |
Should tasks be connectable? Is there another construct that looks similar to a task that should be?
If we provide a default implementation for Connectable that supports Streams, then a connectable task would look exactly like
Stream.once(fun)
The text was updated successfully, but these errors were encountered: