aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Harning Jr <harningt@gmail.com>2007-11-25 18:05:17 -0500
committerThomas Harning Jr <harningt@gmail.com>2007-11-25 18:05:17 -0500
commitd1943eda4282c598352916aeeb2f23c128d8fa90 (patch)
tree6fe9b60d43819708910aac141d1994b0c58ae74c
parent68736d02322f59130b1b407b483f4d507609d024 (diff)
downloadluaevent-prosody-d1943eda4282c598352916aeeb2f23c128d8fa90.tar.gz
luaevent-prosody-d1943eda4282c598352916aeeb2f23c128d8fa90.zip
bufferevent learned set_*_watermarks
-rw-r--r--doc/modules/luaevent.core.bufferevent.mdwn10
-rw-r--r--src/buffer_event.c28
2 files changed, 38 insertions, 0 deletions
diff --git a/doc/modules/luaevent.core.bufferevent.mdwn b/doc/modules/luaevent.core.bufferevent.mdwn
index 5c6a398..eeed2fa 100644
--- a/doc/modules/luaevent.core.bufferevent.mdwn
+++ b/doc/modules/luaevent.core.bufferevent.mdwn
@@ -32,3 +32,13 @@ Functions:
## bufferevent:get_write
* Obtains the output buffer associated w/ the bufferevent
+
+## bufferevent:set_read_watermarks
+* Input: `(low, high)`
+ * `low` - Size of buffer at which an event would be fired
+ * `high` - Maximum size of buffer to read to
+
+## bufferevent:set_write_watermarks
+* Input: `(low, high)`
+ * `low` - When buffer is below this, the event will be fired
+ * `high` - N/A to libevent, user app may use this
diff --git a/src/buffer_event.c b/src/buffer_event.c
index 2f5dbcd..5d74db2 100644
--- a/src/buffer_event.c
+++ b/src/buffer_event.c
@@ -141,9 +141,37 @@ static int buffer_event_get_write(lua_State* L) {
return 1;
}
+static int buffer_event_set_read_watermarks(lua_State* L) {
+ int low, high;
+ le_bufferevent* ev = buffer_event_get(L, 1);
+ if(!ev->ev) return 0;
+
+ low = lua_tonumber(L, 2);
+ high = lua_tonumber(L, 3);
+
+ ev->ev->wm_read.low = low;
+ ev->ev->wm_read.high = high;
+ return 0;
+}
+
+static int buffer_event_set_write_watermarks(lua_State* L) {
+ int low, high;
+ le_bufferevent* ev = buffer_event_get(L, 1);
+ if(!ev->ev) return 0;
+
+ low = lua_tonumber(L, 2);
+ high = lua_tonumber(L, 3);
+
+ ev->ev->wm_write.low = low;
+ ev->ev->wm_write.high = high;
+ return 0;
+}
+
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},
{NULL, NULL}
};