From 812007f5bcefbbb95d2a7783d5f6fc0cf9d516ea Mon Sep 17 00:00:00 2001 From: fm Date: Sat, 17 Mar 2012 09:15:07 +0100 Subject: [PATCH] Document lua api --- README | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/README b/README index bad7f57..9de768e 100644 --- a/README +++ b/README @@ -20,6 +20,37 @@ The typical application will do the following steps Lua binding ----------- A lua binding is available that should mix well with luasocket and luaposix. +Time resolutions are in milli second integers in order to support integer-only +embedded environments + +### function luevent.addFileIO(fdesc, handler, mode) +Add a handler on a stream. The handler will sustain itself GC wise. +Use *object*:clear() to unregister the handler +* fdesc The posix file descriptor "small integer". + Use the ":getfd()" method on a "normal" lua stream or socket to obtain fdesc. +* handler A function object. The handler object is supplied as the first parameter when called. +* mode Optional. Input ("r") or output ("w") event. Default is input +* return A new filehandler object + +### function luevent.addTimer(msecs, handler) +Create a new timer object. Implicitly cleared when handler is called. +Typical usage: + local hdl + hdl = luevent.addTimer(50, function() hdl = nil ..... end) + ...... + if hdl then hdl:clear() hdl = nil end +Here *hdl* is used to keep track of whether the timer is active. + +* msecs The number of milliseconds until the timer expires +* handler A function object. The handler object is supplied as the first parameter when called. +* return A new timer object + +### function object:clear() +Cancel a callback registration. Renders the object ready for GC. + +### function object:handler() +Obtain the handler function from a callback registration. + Building -------- @@ -35,5 +66,5 @@ Is purely manual, but would be something along the lines of: sudo install -m 444 libuevent.so.1 /usr/lib/libuevent.so.1 sudo install -m 444 luevent.so /usr/lib/lua/5.1/luevent.so - +