I would like to know if there’s any documentation regarding as_monitor for C api. I see it being used in examples but don’t fully understand what it’s being used for, and how/when it should be used. Can you give me a brief explanation, or point me to any relevant documentation i might have missed.
as_monitor is a thin wrapper around pthread_cond methods that implement “notify” and “wait” calls between separate threads. as_monitor is used to wait in the main thread until the async event loop thread finishes processing it’s queue of tasks. If the main thread did not wait, it could shutdown before all queued commands have finished.
If your main thread is also the event loop thread, then as_monitor is not necessary.
as_monitor is also used in async tests because the test framework itself is synchronous. Each test must complete before validation takes place.