I am trying to understand use cases of Event::defer() however no source on internet (including Swoole's Documentation) is able to explain it, precisely.
Same is for Event-Loops' tick.
Event::defer() delays the execution of the code after the current on-giong Event Loop tick / iteration, (or, before the start of next iteration / tick).
Question-1: What is / are the good use case/s which can help understand the significance of doing that Event:defer() ? In other words, what we can achieve from doing that Event::Defer() ?
Question-2:
Does one Tick (which i assume as one iteration) of Event Loop, triggers the handling of multiple different "Types" of I/O-Events (like all pending onConnect and on open reqeuests and pending onMessage events and pending onClose and pending onDisconnect events) in each single Tick (Iteration) ? OR each "Type" of I/O-event executes in different iteratoins ?
Quetion-3:
When onMessage handler is triggered for each "fd" as part of a Event-loop's Tick, do the Coroutine's, which we create inside handler (Callback), also trigger within same tick ?
Question-4:
When i call an Event:defer() from inside an onMessage callback (handler), will it run only once (globally) for all Messages for all Fds ?
OR
It will run for each fd by retaining the context of Message (which means, by retaining the data sent to that fd, in the current message) ?
I am trying to understand use cases of Event::defer() however no source on internet (including Swoole's Documentation) is able to explain it, precisely.
Same is for Event-Loops' tick.
Event::defer() delays the execution of the code after the current on-giong Event Loop tick / iteration, (or, before the start of next iteration / tick).
Question-1: What is / are the good use case/s which can help understand the significance of doing that Event:defer() ? In other words, what we can achieve from doing that Event::Defer() ?
Question-2:
Does one Tick (which i assume as one iteration) of Event Loop, triggers the handling of multiple different "Types" of I/O-Events (like all pending onConnect and on open reqeuests and pending onMessage events and pending onClose and pending onDisconnect events) in each single Tick (Iteration) ? OR each "Type" of I/O-event executes in different iteratoins ?
Quetion-3:
When onMessage handler is triggered for each "fd" as part of a Event-loop's Tick, do the Coroutine's, which we create inside handler (Callback), also trigger within same tick ?
Question-4:
When i call an Event:defer() from inside an onMessage callback (handler), will it run only once (globally) for all Messages for all Fds ?
OR
It will run for each fd by retaining the context of Message (which means, by retaining the data sent to that fd, in the current message) ?