You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The diagram simplifies the interplay between Executor and Reactor by lumping reactor with Resource(I/O) and Operating System.
While it'd be easier to understand for those who got to learn async rust for the first time, combining those three seem quite off.
I like to suggest the following diagram if it is not too complex
sequenceDiagram
participant E as Executor
participant F as Future (Task)
participant OS as Operating System<br/>(e.g., epoll/kqueue)
participant R as Reactor (Runtime)
E->>F: Calls poll(cx)
Note right of F: Future attempts operation
F->>OS: Syscall (e.g., read TCP socket #4)
OS-->>F: Returns Error: (Not Ready)
F->>R: Registers: (Waker)
F-->>E: Returns Poll::Pending
Note left of E: Task is moved out<br/>of run queue
E->>E: (Executor runs other tasks OR sleeps)
R->>OS: epoll_wait() / Polls OS for events
Note right of OS: (Sometime Later) New data arrives
OS-->>R: Wakes Reactor: data is NOW READABLE
Note over R: OS NOTIFIES REACTOR FIRST
R->>R: Reactor finds Waker
R->>E: Calls Waker::wake()
Note right of E: Task is pushed back<br/>to Executor's run queue
E->>F: Calls poll(cx) again
Note right of F: Future attempts operation again
F->>OS: Syscall (e.g., read TCP socket #4)
OS-->>F: Success: Returns Data Buffer
F-->>E: Returns Poll::Ready(Data)
The diagram simplifies the interplay between Executor and Reactor by lumping reactor with Resource(I/O) and Operating System.
While it'd be easier to understand for those who got to learn async rust for the first time, combining those three seem quite off.
I like to suggest the following diagram if it is not too complex
sequenceDiagram participant E as Executor participant F as Future (Task) participant OS as Operating System<br/>(e.g., epoll/kqueue) participant R as Reactor (Runtime) E->>F: Calls poll(cx) Note right of F: Future attempts operation F->>OS: Syscall (e.g., read TCP socket #4) OS-->>F: Returns Error: (Not Ready) F->>R: Registers: (Waker) F-->>E: Returns Poll::Pending Note left of E: Task is moved out<br/>of run queue E->>E: (Executor runs other tasks OR sleeps) R->>OS: epoll_wait() / Polls OS for events Note right of OS: (Sometime Later) New data arrives OS-->>R: Wakes Reactor: data is NOW READABLE Note over R: OS NOTIFIES REACTOR FIRST R->>R: Reactor finds Waker R->>E: Calls Waker::wake() Note right of E: Task is pushed back<br/>to Executor's run queue E->>F: Calls poll(cx) again Note right of F: Future attempts operation again F->>OS: Syscall (e.g., read TCP socket #4) OS-->>F: Success: Returns Data Buffer F-->>E: Returns Poll::Ready(Data)