mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-12 05:48:51 -04:00
r15317@tombo: nickm | 2008-04-24 21:17:49 -0400
Add new functions to be more threadsafe (and structure-ignorant) than event_set. svn:r726
This commit is contained in:
parent
49868b618a
commit
94fb4d0a1e
@ -69,6 +69,7 @@ Changes in current version:
|
|||||||
o Add new thread-safe interfaces to evdns functions.
|
o Add new thread-safe interfaces to evdns functions.
|
||||||
o Make all event_tagging interfaces threadsafe.
|
o Make all event_tagging interfaces threadsafe.
|
||||||
o Rename internal memory management functions.
|
o Rename internal memory management functions.
|
||||||
|
o New functions (event_assign, event_new, event_free) for use by apps that want to be safely threadsafe, or want to remain ignorant of the contents of struct event.
|
||||||
|
|
||||||
Changes in 1.4.0:
|
Changes in 1.4.0:
|
||||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||||
|
30
event.c
30
event.c
@ -664,6 +664,36 @@ event_base_set(struct event_base *base, struct event *ev)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
|
||||||
|
{
|
||||||
|
event_set(ev, fd, events, cb, arg);
|
||||||
|
return event_base_set(base, ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct event *
|
||||||
|
event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
|
||||||
|
{
|
||||||
|
struct event *ev;
|
||||||
|
ev = mm_malloc(sizeof(struct event));
|
||||||
|
if (!ev)
|
||||||
|
return NULL;
|
||||||
|
if (event_assign(ev, base, fd, events, cb, arg) < 0) {
|
||||||
|
mm_free(ev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
event_free(struct event *ev)
|
||||||
|
{
|
||||||
|
/* make sure that this event won't be coming back to haunt us.
|
||||||
|
* XXX this is safe, right? */
|
||||||
|
event_del(ev);
|
||||||
|
mm_free(ev);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set's the priority of an event - if an event is already scheduled
|
* Set's the priority of an event - if an event is already scheduled
|
||||||
* changing the priority is going to fail.
|
* changing the priority is going to fail.
|
||||||
|
@ -285,6 +285,13 @@ int event_base_loopbreak(struct event_base *);
|
|||||||
*/
|
*/
|
||||||
void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
|
void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
|
||||||
|
|
||||||
|
/*XXX document this function, deprecate previous one. */
|
||||||
|
int event_assign(struct event *, struct event_base *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
|
||||||
|
|
||||||
|
struct event *event_new(struct event_base *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
|
||||||
|
|
||||||
|
void event_free(struct event *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Schedule a one-time event (threadsafe variant)
|
Schedule a one-time event (threadsafe variant)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user