Designing concurrent code
Project complexity rises drastically when concurrency is introduced. It’s much easier to deal with sequentially executing synchronous code compared to concurrent counterparts. Many systems avoid using multithreading at all by introducing event-driven development concepts, such as event loops. The point of using an event loop is to introduce a manageable approach to asynchronous programming. To take this concept further, imagine any application providing a graphical user interface (GUI). Whenever the user clicks on any GUI component, such as buttons, types in fields, or even moves the mouse, the application receives so-called events regarding the user action. Whether it’s button_press
, button_release
, mouse_move
, or any other event, it represents a piece of information for the application to use to react properly. A popular approach is to incorporate an event loop to queue any event that occurred during user interaction.
While the application...