diff options
Diffstat (limited to 'src/events.h')
-rw-r--r-- | src/events.h | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/events.h b/src/events.h index 3715b4d66..434c39d80 100644 --- a/src/events.h +++ b/src/events.h @@ -16,18 +16,49 @@ struct rspamd_async_event { struct rspamd_async_session { event_finalizer_t fin; - GQueue *events; + event_finalizer_t cleanup; + GHashTable *events; + GQueue *forced_events; void *user_data; memory_pool_t *pool; gboolean wanna_die; }; -/* Makes new async session */ -struct rspamd_async_session *new_async_session (memory_pool_t *pool, event_finalizer_t fin, void *user_data); -/* Insert event into session */ -void register_async_event (struct rspamd_async_session *session, event_finalizer_t fin, void *user_data, gboolean forced); -/* Must be called by forced events to call session destructor properly */ +/** + * Make new async session + * @param pool pool to alloc memory from + * @param fin a callback called when no events are found in session + * @param cleanup a callback called when session is forcefully destroyed + * @param user_data abstract user data + * @return + */ +struct rspamd_async_session *new_async_session (memory_pool_t *pool, + event_finalizer_t fin, event_finalizer_t cleanup, void *user_data); + +/** + * Insert new event to the session + * @param session session object + * @param fin finalizer callback + * @param user_data abstract user_data + * @param forced session cannot be destroyed until forced event are still in it + */ +void register_async_event (struct rspamd_async_session *session, + event_finalizer_t fin, void *user_data, gboolean forced); + + +/** + * Remove forced event + * @param session session object + * @param fin destructor function + */ void remove_forced_event (struct rspamd_async_session *session, event_finalizer_t fin); + +/** + * Remove normal event + * @param session session object + * @param fin final callback + * @param ud user data object + */ void remove_normal_event (struct rspamd_async_session *session, event_finalizer_t fin, void *ud); /** @@ -36,4 +67,11 @@ void remove_normal_event (struct rspamd_async_session *session, event_finalizer_ */ gboolean destroy_session (struct rspamd_async_session *session); +/** + * Check session for events pending and call fin callback if no events are pending + * @param session session object + * @return TRUE if session has pending events + */ +gboolean check_session_pending (struct rspamd_async_session *session); + #endif /* RSPAMD_EVENTS_H */ |