Function anjay_event_loop_interrupt
Defined in File core.h
Function Documentation
-
int anjay_event_loop_interrupt(anjay_t *anjay)
Interrupts an ongoing execution of anjay_event_loop_run.
This function may be called from another thread, or from a callback running within the event loop itself.
After the call to this function, the event loop will finish as soon as possible while gracefully executing any outstanding tasks.
Please note that the event loop may not be interrupted immediately and instead wait until either of the following:
any ongoing scheduler tasks finish
any incoming operation involving a blockwise transfer finishes
the
pollorselect()operation finishes (see themax_wait_timeargument to anjay_event_loop_run)
Interrupting the two latter cases may be possible by performing a system-specific call that would interrupt ongoing socket operations (e.g. raising a signal with an appropriately crafted signal handler on Unix-like systems) immediately after having called
anjay_event_loop_interrupt().Please note that this function always returns immediately, without waiting for the event loop to actually finish. Please use an appropriate system API (e.g.
pthread_join()on Unix-like systems) if you need to ensure that the event loop has finished.- Parameters:
anjay – Anjay object to operate on.
- Returns:
0 if the interrupt has been successfully raised, or a negative value if the event loop is either not running or already in the process of finishing due to a previous interrupt.