Last active
November 2, 2020 22:30
-
-
Save trevnorris/a97348625e81b8f6607925529788d4a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example Event Loop Execution Timeline | |
L₁ L₂ L₃ L₄ | |
(1) ━━━┪ ┏━━━━━━━━━━━━━━╈┳━━━━━━━━━┯━━━━━━━━━━━╈┳━━━━┓ ┢━━━━━ | |
┃ ┃ e₁ ┃┃ e₂ │ e₃ ┃┃ e₄ ┃ ┃ e₅ | |
───┨ ┠──────────────┨┠─────────┼───────────╂╂────┨ ┠───── | |
(2) ┄┄┄┺━━━╃┄┄┄┄┄┄┄┄┄┄┄┄┄┄┺╃┄┄┄┄┄┄┄┄┄┴┄┄┄┄┄┄┄┄┄┄┄┺╃┄┄┄┄┺━━━━╃┄┄┄┄┄ | |
│ [e₂] [e₃] │ [e₄] │ │ | |
[e₁] [e₂] [e₄] [e₅] | |
[e₃] | |
(1) is the event handler. (2) is the event queue. | |
L₁ | |
▻ Event loop begins to idle and wait for an event. | |
▻ e₁ is placed in the event queue and immediately dispatched to the event handler. | |
▻ While e₁ is being processed, e₂ and e₃ are placed in the event queue. | |
▻ The duration of time between when L₁ starts and | |
e₁ is dispatched will be measured as the event provider's idle time. | |
L₂ | |
▻ The event provider is entered and immediately receives | |
events e₂ and e₃. | |
▻ While e₂ and e₃ are being processed, e₄ is placed in the event queue. | |
▻ Because an event was waiting in the event queue, the idle time does not increase. | |
L₃ | |
▻ e₄ is immediately received and processed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment