mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Make bufferevent_trigger_nolock_() inline
Since most of its callers are using constant EV_READ or EV_WRITE, and using constant 0 as its argument, this should eliminate most of the overhead for this function in the fast case.
This commit is contained in:
parent
b4ef3def6f
commit
4dd3abd41f
@ -354,8 +354,21 @@ void bufferevent_run_eventcb_(struct bufferevent *bufev, short what, int options
|
||||
* BEV_TRIG_DEFER_CALLBACKS) I/O callbacks specified in iotype.
|
||||
* Must already hold the bufev lock. Honors watermarks unless
|
||||
* BEV_TRIG_IGNORE_WATERMARKS is in options. */
|
||||
void bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options);
|
||||
static inline void bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options);
|
||||
|
||||
/* Making this inline since all of the common-case calls to this function in
|
||||
* libevent use constant arguments. */
|
||||
size_t evbuffer_get_length(const struct evbuffer *buf);
|
||||
static inline void
|
||||
bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
|
||||
{
|
||||
if ((iotype & EV_READ) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
|
||||
evbuffer_get_length(bufev->input) >= bufev->wm_read.low))
|
||||
bufferevent_run_readcb_(bufev, options);
|
||||
if ((iotype & EV_WRITE) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
|
||||
evbuffer_get_length(bufev->output) <= bufev->wm_write.low))
|
||||
bufferevent_run_writecb_(bufev, options);
|
||||
}
|
||||
|
||||
/** Internal: Add the event 'ev' with timeout tv, unless tv is set to 0, in
|
||||
* which case add ev with no timeout. */
|
||||
|
@ -252,17 +252,6 @@ bufferevent_run_writecb_(struct bufferevent *bufev, int options)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
|
||||
{
|
||||
if ((iotype & EV_READ) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
|
||||
evbuffer_get_length(bufev->input) >= bufev->wm_read.low))
|
||||
bufferevent_run_readcb_(bufev, options);
|
||||
if ((iotype & EV_WRITE) && ((options & BEV_TRIG_IGNORE_WATERMARKS) ||
|
||||
evbuffer_get_length(bufev->output) <= bufev->wm_write.low))
|
||||
bufferevent_run_writecb_(bufev, options);
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_trigger(struct bufferevent *bufev, short iotype, int options)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user