diff options
author | Thomas Harning Jr <harningt@gmail.com> | 2007-11-25 18:08:11 -0500 |
---|---|---|
committer | Thomas Harning Jr <harningt@gmail.com> | 2007-11-25 18:08:11 -0500 |
commit | fead5abe2ad7d185e3a2434d5e1695193339adf5 (patch) | |
tree | 0f4876e3069621452cf491573b7c420c18d27b3c | |
parent | d1943eda4282c598352916aeeb2f23c128d8fa90 (diff) | |
download | luaevent-prosody-fead5abe2ad7d185e3a2434d5e1695193339adf5.tar.gz luaevent-prosody-fead5abe2ad7d185e3a2434d5e1695193339adf5.zip |
bufferevent learned get_*_watermarks
-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} }; |