summaryrefslogtreecommitdiffstats
path: root/src/events.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-22 20:22:31 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-22 20:22:31 +0400
commit626a11ad9819593eadaca1e321192c75a32b51f3 (patch)
tree7f062ddf5d6ec04d7e2f4009541aa417df1cfe59 /src/events.h
parentfe815ce580d3c455292e1acda406ddb4d371120a (diff)
downloadrspamd-626a11ad9819593eadaca1e321192c75a32b51f3.tar.gz
rspamd-626a11ad9819593eadaca1e321192c75a32b51f3.zip
* Implement new system of async events handling (experimental)
Diffstat (limited to 'src/events.h')
-rw-r--r--src/events.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/events.h b/src/events.h
new file mode 100644
index 000000000..3715b4d66
--- /dev/null
+++ b/src/events.h
@@ -0,0 +1,39 @@
+#ifndef RSPAMD_EVENTS_H
+#define RSPAMD_EVENTS_H
+
+#include "config.h"
+
+struct rspamd_async_event;
+
+typedef void (*event_finalizer_t)(void *user_data);
+
+struct rspamd_async_event {
+ event_finalizer_t fin;
+ void *user_data;
+ gboolean forced;
+ guint ref;
+};
+
+struct rspamd_async_session {
+ event_finalizer_t fin;
+ GQueue *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 */
+void remove_forced_event (struct rspamd_async_session *session, event_finalizer_t fin);
+void remove_normal_event (struct rspamd_async_session *session, event_finalizer_t fin, void *ud);
+
+/**
+ * Must be called at the end of session, it calls fin functions for all non-forced callbacks
+ * @return true if the whole session was destroyed and false if there are forced events
+ */
+gboolean destroy_session (struct rspamd_async_session *session);
+
+#endif /* RSPAMD_EVENTS_H */