Skip to content

Separate the event loop handling into a separate layer

Ondřej Surý requested to merge ondrej-add-isc-loopmgr into main


  • an application built on top of libisc libraries were using isc_app as the base unit for running the application and signal handling. The isc_app would start the extra threads (f.e. the networking, the timers) and block and idle.

  • the networking was handled in the netmgr layer that would start number of threads each with uv_loop event loop

  • the task/event handling was done in the isc_task unit that was using the netmgr event loops to run the isc_event calls

  • the timers (isc_timer) started own thread and pushed the scheduled events to assigned tasks (isc_task)

In this refactoring, this code was modified or changed:

  • isc_app was replaced with isc_loopmgr that handled the application start and stop, and the main thread is no longer blocked, but it's part of the thread set.

  • the signal handling is now a separate isc_signal unit - the isc_loopmgr only handles SIGTERM and SIGINT for application termination, but the application can install their own handlers (f.e. SIGHUP to reload the configuration)

  • the event loops from the netmgr were moved into isc_loopmgr that now starts and stop the threads with the event loops (isc_loop)

  • the netmgr code now uses the isc_loop instead of maintaining own threads and event loops

  • the taskmgr that manages the isc_task instances is now also using isc_loopmgr, and every isc_task runs on a specific isc_loop bound to the specific thread

  • the timers were rewritten using the uv_timer and isc_timermgr_t was completely removed - the isc_timers are directly created on the event loops

  • the new job running primitives - isc_job and isc_async were added. Both units schedule callbacks (+ callback argument) on the event loop. The difference is that isc_job unit is unlocked and not thread-safe, while isc_async is thread-safe and uses locking.

Closes #3508 (closed)

Edited by Ondřej Surý

Merge request reports