-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
The current design is a bit too rigid. The only moment a Task can communicate back to the Scope is when the Task finishes and returns a value.
The current way to communicate while still running the Task is to use sockets. The advantage is that it keeps the implementation simple as it uses the IO abstraction. However it is slow as it goes through the network system.
Also it creates a design problem. For 2 tasks, or scope, to communicate one needs to use a pair of socket. One of the sockets is then referenced on the other side, meaning within a different Fiber. This means that a Task use a socket created by a different OperatingSystem instance than the one being created for this Task.
This design prevents Innmind/actors#2 to use the latest packages versions.
Solution
Create a new Channel object that is passed for each new Task alongside the dedicated OS. This channel allows to send notifications back to the Scope and wait to receive notifications from the Scope. The Scope now has access to these notifications in a similar way to results.
This means that a communication between 2 tasks must go through the Scope to dispatch these notifications. This constraint allows the design to remain simple and predictable.
final class Channel
{
public function send(mixed): void;
public function receive(?Period): Maybe<mixed>;
}