Concurrency Models: Event-Based System

Concurrency Models: Event-Based System

2022, Mar 12    

Event-Based System

Event loop concept

Node-Js / Netty / Vert.x are popular frameworks which uses concept of Event Loop.

Components of Event-Loop based system:

  • Main thread submits tasks to a task queue.
  • The event loop constantly monitors the task queue/ring buffer and runs the task until it counters I/O tasks.
  • In I/O task case, the event loop pauses the task and hands it over to the OS.
  • Event-Loop even check for the completed IO tasks. If the task is completed, the OS will notify the program. The event loop then runs the unpaused tasks.
  • In OS, the syscalls select() and poll() helps to keep track of IO bound tasks.
  • There is no need to acquire or release locks in evented system, since events are expected to non-blocking of each other.