Skip to main content
Definition Website Computer and Technology

Event Loop

Subject: Computer and Technology noun /ɪˈvɛnt luːp/ 1 definition

  1. Definition (noun)

    Entry #5 · Updated

    An Event Loop is a concurrency control mechanism that continuously waits for incoming events, I/O readiness notifications, or queued callbacks and dispatches them sequentially for execution. By delegating slow operations such as network requests, disk reads, or timers to the operating system or background workers and resuming work only when results arrive, it enables responsive, non-blocking execution without the locking overhead of preemptive multi-threading. Unlike parallel thread pools that run heavy computations simultaneously across CPU cores, an event loop coordinates asynchronous control flow on a single thread and therefore relies on handlers remaining short and non-blocking.

    Common Forms

    • Browser and JavaScript Runtime Loop: Coordinates the call stack, microtask queue (such as resolved Promises), macrotask queue, and frame rendering in web browsers and server runtimes like Node.js.

    • Asynchronous I/O Multiplexing Loop: Uses kernel notification mechanisms such as epoll, kqueue, or io_uring in servers and frameworks like Nginx, Redis, or Python asyncio to manage thousands of network connections on minimal threads.

    • Graphical User Interface (GUI) Message Loop: Continuously polls operating system input queues for mouse clicks, keystrokes, and repaint events to keep desktop and mobile applications responsive.

    Example

    When a Node.js API server queries a PostgreSQL database, the event loop registers a completion callback and immediately moves on to serve other incoming HTTP requests instead of sitting idle. Once the database returns the query rows, the event loop picks up the queued callback from the poll phase and sends the JSON response back to the client.