event loop


Also found in: Dictionary, Thesaurus, Medical, Legal, Financial, Wikipedia.

event loop

A programming structure that continually tests for external events and calls the appropriate routines to handle them. An event loop is often the main loop in a program that typically waits for the user to trigger something. The following example is the main loop in the first software engine for this encyclopedia. Written in Turbo C, the main loop is constantly testing for menu selections, keystrokes and mouse clicks.

Functions
The statements with double parentheses are calls to functions (subroutines). For example, the bookmark() function creates a bookmark, and control is returned to the break statement. Break creates a go-to instruction to the beginning of the loop.

While
The while (1) statement creates a continuous loop until some condition is satisfied. In this example, the (1) means always true and keeps looping continuously. At the bottom (END OF EVENT LOOP), the curly brace (}) tells the compiler to insert a go-to instruction at that point that jumps to the beginning of the loop.

Switch
When testing for several conditions, the switch statement saves the programmer from having to write compare statements multiple times (if something is equal to, greater than or less than something else). In this example, the numbers are keyboard key codes (what key was just pressed?). See C, curly brace, event, event handler and event driven.


Copyright © 1981-2019 by The Computer Language Company Inc. All Rights reserved. THIS DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher.
References in periodicals archive ?
while (TRUE) { if (sensorA () < 100) {beep ();} } It is easy to denote an event loop because of its simple structure as shown above, but it is essential to consider the consistency of events that may occur.
The goal of all the modules is to make the event loop as fast as possible.
This single-thread-of-control phenomenon is sometimes called the "Hollywood principle," or "don't call us, we'll call you" and "flip-flop of control." The inversion of control occurs when two or more frameworks call the application code simultaneously, each assuming ownership of the application's main event loop. The complexity of this problem increases along with the increasing number of frameworks that have to be integrated in the application.
“Our tests on a setup with 4000 services shows a tenfold improvement from 3 minutes to just 3 seconds till event loop start.
The Reactor pattern manages a single-threaded event loop that performs event demultiplexing and event handler dispatching in response to events from multiple sources.