Module <cweb/async.h> — callback on the event loop
Defers execution of a callback until the next libevent loop iteration — useful for safely returning “onto the loop” from interrupt-like contexts or nested calls.
Type cweb_async_cb
typedef void (*cweb_async_cb)(void *user_data);
Function
int cweb_async(cweb_async_cb cb, void *user_data)
- Purpose: Schedules
cb(user_data)on the sameevent_baseas the server. - Parameters:
cb— function with no return value.user_data— optionalNULL.
- Return:
0on success, otherwise error code (implementation).
Notes
- Not a full job queue — only simple “defer to loop”.
- Requires initialized global event base (
cweb_run_server/g_event_base).