src/server/daemon/event.c

changeset 193
aa8393527b1e
parent 159
9ba9f8befa80
child 254
4784c14aa639
--- a/src/server/daemon/event.c	Thu Aug 31 16:29:49 2017 +0200
+++ b/src/server/daemon/event.c	Sat Jan 13 19:01:00 2018 +0100
@@ -26,16 +26,17 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <ucx/map.h>
+#include "../../ucx/map.h"
+#include "../util/atomic.h"
 
 #include "event.h"
 
 UcxMap *event_handler_map = NULL;
 int numevhandlers = 0;
 
-event_handler_t *default_event_handler = NULL;
+EVHandler *default_event_handler = NULL;
 
-event_handler_t *last_handler_c = NULL;
+EVHandler *last_handler_c = NULL;
 
 int create_event_handler(EventHandlerConfig *cfg) {
     if(event_handler_map == NULL) {
@@ -50,7 +51,7 @@
     }
     
     /* create new handler */
-    event_handler_t *e = evhandler_create(cfg->nthreads);
+    EVHandler *e = evhandler_create(cfg);
     if(e == NULL) {
         return 1;
     }
@@ -95,10 +96,21 @@
 }
 
 
-event_handler_t* get_default_event_handler() {
+EVHandler* get_default_event_handler() {
     return default_event_handler;
 }
 
-event_handler_t* get_event_handler(char *name) {
+EVHandler* get_event_handler(char *name) {
     return ucx_map_cstr_get(event_handler_map, name);
 }
+
+EventHandler* ev_instance(EVHandler *ev) {
+    int nev = ev->numins;
+    if(nev == 1) {
+        return ev->instances[0];
+    }
+    
+    int ins = ev->current & nev;
+    ws_atomic_inc32(&ev->current);
+    return ev->instances[ins];
+}

mercurial