Add a bufferevent_get_priority() function

This commit is contained in:
Nick Mathewson 2012-05-08 18:04:19 -04:00
parent f90e25593c
commit bd395549a3
2 changed files with 16 additions and 0 deletions

View File

@ -397,6 +397,16 @@ bufferevent_get_base(struct bufferevent *bufev)
return bufev->ev_base; return bufev->ev_base;
} }
int
bufferevent_get_priority(struct bufferevent *bufev)
{
if (event_initialized(&bufev->ev_read)) {
return event_get_priority(&bufev->ev_read);
} else {
return event_base_get_npriorities(bufev->ev_base) / 2;
}
}
int int
bufferevent_write(struct bufferevent *bufev, const void *data, size_t size) bufferevent_write(struct bufferevent *bufev, const void *data, size_t size)
{ {

View File

@ -273,6 +273,12 @@ struct event_base *bufferevent_get_base(struct bufferevent *bev);
*/ */
int bufferevent_priority_set(struct bufferevent *bufev, int pri); int bufferevent_priority_set(struct bufferevent *bufev, int pri);
/**
Return the priority of a bufferevent.
Only supported for socket bufferevents
*/
int bufferevent_get_priority(struct bufferevent *bufev);
/** /**
Deallocate the storage associated with a bufferevent structure. Deallocate the storage associated with a bufferevent structure.