mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Add bufferevent_lock()/bufferevent_unlock()
Although bufferevent operations are threadsafe, sometimes you need to make sure that a few operations on a single bufferevent will all be executed with nothing intervening. That's what these functions are for.
This commit is contained in:
parent
7b259b6796
commit
215e629cd4
@ -825,3 +825,17 @@ _bufferevent_add_event(struct event *ev, const struct timeval *tv)
|
|||||||
else
|
else
|
||||||
return event_add(ev, tv);
|
return event_add(ev, tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For use by user programs only; internally, we should be calling
|
||||||
|
either _bufferevent_incref_and_lock(), or BEV_LOCK. */
|
||||||
|
void
|
||||||
|
bufferevent_lock(struct bufferevent *bev)
|
||||||
|
{
|
||||||
|
_bufferevent_incref_and_lock(bev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bufferevent_unlock(struct bufferevent *bev)
|
||||||
|
{
|
||||||
|
_bufferevent_decref_and_unlock(bev);
|
||||||
|
}
|
||||||
|
@ -423,6 +423,18 @@ int bufferevent_set_timeouts(struct bufferevent *bufev,
|
|||||||
void bufferevent_setwatermark(struct bufferevent *bufev, short events,
|
void bufferevent_setwatermark(struct bufferevent *bufev, short events,
|
||||||
size_t lowmark, size_t highmark);
|
size_t lowmark, size_t highmark);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Acquire the lock on a bufferevent. Has no effect if locking was not
|
||||||
|
enabled with BEV_OPT_THREADSAFE.
|
||||||
|
*/
|
||||||
|
void bufferevent_lock(struct bufferevent *bufev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Release the lock on a bufferevent. Has no effect if locking was not
|
||||||
|
enabled with BEV_OPT_THREADSAFE.
|
||||||
|
*/
|
||||||
|
void bufferevent_unlock(struct bufferevent *bufev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Flags that can be passed into filters to let them know how to
|
Flags that can be passed into filters to let them know how to
|
||||||
deal with the incoming data.
|
deal with the incoming data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user