This repository was archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Overview
kmussel edited this page Dec 17, 2010
·
4 revisions
Libevent is used for our event notification system. You can look at documentation on Libevent at http://monkey.org/~provos/libevent/ or http://www.wangafu.net/~nickm/libevent-book/
In CoreJS we use it in two different ways:
The Very General Flow Of Libevent
- Create a new base to add all of our events to.
*
struct event_base *base = event_base_new(); - Create a new event *
struct event * event_new(struct event_base *base, evutil_socket_t fd, short what, event_callback_fn cb, void *arg);- Add the event to the event_base *
event_add(struct event * ev, NULL);- Start the loop to begin listening for the added events *
event_base_dispatch(event_base);How We Use It
We wanted to be able to have event notification across threads so we create a single instance of libevent's event_base. We created a singleton class called BaseEvent that contains this event_base. All events are added to this base.