When starting the event loop in libuv using the uv_run function uv_run there is a "mode" parameter, which is used with the following values:
UV_RUN_DEFAULT UV_RUN_ONCE UV_RUN_NOWAIT
The first two are obvious. UV_RUN_DEFAULT starts a cycle of events until there are no more events, and UV_RUN_ONCE process one event from a cycle. However, UV_RUN_NOWAIT not a separate mode, but rather a flag, which can be ORed with one of two other values.
By default, this function is blocked until events are processed, and UV_RUN_NOWAIT makes it non-blocking, but any documentation that I can find on it ends there. My question is: if you run a non-blocking event loop, how are callbacks handled?
The libuv event model is single-threaded (reactor template), so I assume that it must be blocked in order to be able to call callbacks, but if the main thread is busy, what happens to the event after it is processed? Will the callback be queued until libuv takes control of the main thread again? Or will calls be sent to another thread?
Alexis king
source share