diff options
-rw-r--r-- | doc/modules/luaevent.core.bufferevent.mdwn | 8 | ||||
-rw-r--r-- | src/buffer_event.c | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/doc/modules/luaevent.core.bufferevent.mdwn b/doc/modules/luaevent.core.bufferevent.mdwn index eeed2fa..259a638 100644 --- a/doc/modules/luaevent.core.bufferevent.mdwn +++ b/doc/modules/luaevent.core.bufferevent.mdwn @@ -42,3 +42,11 @@ Functions: * Input: `(low, high)` * `low` - When buffer is below this, the event will be fired * `high` - N/A to libevent, user app may use this + +## bufferevent:get_read_watermarks +* Output: `low, high` +* See `set_read_watermarks` + +## bufferevent:get_write_watermarks +* Output: `low, high` +* See `set_write_watermarks` diff --git a/src/buffer_event.c b/src/buffer_event.c index 5d74db2..e32fa04 100644 --- a/src/buffer_event.c +++ b/src/buffer_event.c @@ -167,11 +167,31 @@ static int buffer_event_set_write_watermarks(lua_State* L) { return 0; } +static int buffer_event_get_read_watermarks(lua_State* L) { + le_bufferevent* ev = buffer_event_get(L, 1); + if(!ev->ev) return 0; + + lua_pushinteger(L, ev->ev->wm_read.low); + lua_pushinteger(L, ev->ev->wm_read.high); + return 2; +} + +static int buffer_event_get_write_watermarks(lua_State* L) { + le_bufferevent* ev = buffer_event_get(L, 1); + if(!ev->ev) return 0; + + lua_pushinteger(L, ev->ev->wm_write.low); + lua_pushinteger(L, ev->ev->wm_write.high); + return 2; +} + static luaL_Reg buffer_event_funcs[] = { {"get_read", buffer_event_get_read}, {"get_write", buffer_event_get_write}, {"set_read_watermarks", buffer_event_set_read_watermarks}, {"set_write_watermarks", buffer_event_set_write_watermarks}, + {"get_read_watermarks", buffer_event_get_read_watermarks}, + {"get_write_watermarks", buffer_event_get_write_watermarks}, {NULL, NULL} }; |