mowgli_eventloop_t * mowgli_eventloop_create(void) { mowgli_eventloop_t *eventloop; if (eventloop_heap == NULL) eventloop_heap = mowgli_heap_create(sizeof(mowgli_eventloop_t), 16, BH_NOW); eventloop = mowgli_heap_alloc(eventloop_heap); eventloop->eventloop_ops = &_mowgli_null_pollops; #ifdef HAVE_SELECT eventloop->eventloop_ops = &_mowgli_select_pollops; #endif #ifdef HAVE_POLL_H eventloop->eventloop_ops = &_mowgli_poll_pollops; #endif #ifdef HAVE_SYS_EPOLL_H eventloop->eventloop_ops = &_mowgli_epoll_pollops; #endif #ifdef HAVE_KQUEUE eventloop->eventloop_ops = &_mowgli_kqueue_pollops; #endif #ifdef HAVE_DISPATCH_BLOCK eventloop->eventloop_ops = &_mowgli_qnx_pollops; #endif #ifdef HAVE_PORT_CREATE eventloop->eventloop_ops = &_mowgli_ports_pollops; #endif #if 0 eventloop->eventloop_ops = &_mowgli_winsock_pollops; #endif if (mowgli_mutex_init(&eventloop->mutex) != 0) { mowgli_log("couldn't create mutex for eventloop %p, aborting...", (void *) eventloop); abort(); } eventloop->eventloop_ops->pollsetup(eventloop); eventloop->deadline = -1; mowgli_eventloop_calibrate(eventloop); return eventloop; }
mowgli_mutex_t * mowgli_mutex_create(void) { mowgli_mutex_t *mutex = mowgli_alloc(sizeof(mowgli_mutex_t)); return_val_if_fail(mutex != NULL, NULL); if (mowgli_mutex_init(mutex)) { return mutex; } else { mowgli_free(mutex); return NULL; } }
void mowgli_interface_bootstrap(void) { mowgli_interface_dict = mowgli_patricia_create(NULL); mowgli_mutex_init(&mowgli_interface_lock); }