aboutsummaryrefslogtreecommitdiffstats
path: root/doc/modules
diff options
context:
space:
mode:
Diffstat (limited to 'doc/modules')
-rw-r--r--doc/modules/luaevent.core.buffer.mdwn60
-rw-r--r--doc/modules/luaevent.core.bufferevent.mdwn67
-rw-r--r--doc/modules/luaevent.core.mdwn67
-rw-r--r--doc/modules/luaevent.mdwn0
4 files changed, 194 insertions, 0 deletions
diff --git a/doc/modules/luaevent.core.buffer.mdwn b/doc/modules/luaevent.core.buffer.mdwn
new file mode 100644
index 0000000..3ae8579
--- /dev/null
+++ b/doc/modules/luaevent.core.buffer.mdwn
@@ -0,0 +1,60 @@
+----
+Functions:
+
+[[toc levels=1]]
+
+## buffer.new
+* Instantiates a new buffer object
+
+## buffer:add
+* Successively concatenates each of the arguments onto the buffer
+* Input: `(...)`
+ * Sequence of strings or buffer instances
+* Side Effects: Buffers 'add'ed are emptied of their contents (per libevent semantics)
+* Output: Amount of data added
+(QUESTION: Should add return the buffer itself so that chaining can be easy)
+
+## buffer:length (__len)
+* Output: Length of the remaining buffer contents
+
+## buffer:get\_data (__tostring)
+* Input:
+ * `()` and `__tostring` - Returns all data in the buffer
+ * `(len)` - Returns data up to `len` bytes long
+ * `(begin, len)` - Returns data beginning at `begin` up to `len` bytes long
+ * If `begin < 0`, wraps at data length. Ex: (-1, 1) returns last byte, (-2, 2) returns last 2 bytes
+* Output: A copy of contents from the buffer
+
+## buffer:read
+* Reads data from a file-descriptor/socket into the buffer directly
+* Input: `(fd, length)`
+ * `fd` - File descriptor to read from
+ * `length` - Amount of data to attempt to read into the buffer
+* Output: Length of data actually read into the buffer
+* Side Effects: fd/socket 'drain'ed of data
+
+## buffer:write
+* Attempts to write out all buffer's data to a file-descriptor/socket
+* Input: `(fd, length)`
+ * `fd` - File descriptor to write to
+ * `socket` - [LuaSocket](http://www.luaforge.net/projects/luasocket)-based socket handle
+* Output: Amount of data written
+* Side Effects: buffer 'drain'ed of written data
+
+## buffer:readline
+* Reads a line terminated by either '\r\n', '\n\r', '\r', or, '\n'
+* Output:
+ * If no terminator found: nil
+ * If terminator found: Line returned without terminators
+* NOTE: If a '\r' or '\n' are the last characters in the buffer, then the data is returned even if the
+potential later data would contain the paired '\n' or '\r'. (TODO: Ask libevent list on how this is handled...)
+
+## buffer:drain
+* Removes data from the buffer
+* Input: `(amt)`
+ * If `amt < 0` drains all data due to auto-casting to unsigned int and capping...
+ TODO: Add code to check this condition explicitly for safety
+ * If `amt >= 0`, drain up to amt from the buffer (no problem w/ too-large values)
+
+## buffer:close (__gc)
+* Immediately frees/closes a buffer. Note that
diff --git a/doc/modules/luaevent.core.bufferevent.mdwn b/doc/modules/luaevent.core.bufferevent.mdwn
new file mode 100644
index 0000000..842ee06
--- /dev/null
+++ b/doc/modules/luaevent.core.bufferevent.mdwn
@@ -0,0 +1,67 @@
+----
+Functions:
+
+[[toc levels=1]]
+
+## Read/Write/Error Callback:
+* Input: `(bufferevent, what)`
+ * `bufferevent` - Reference to the bufferevent that raised the callback
+ * `what` - What happened:
+ * == `EVBUFFER_READ` - Buffer contains at least low-watermark length and no more than high-watermark length
+ * == `EVBUFFER_WRITE` - Buffer ready to write to
+ * (other) - Error condition
+ * May be or-ed/added with `EVBUFFER_READ`/`EVBUFFER_WRITE` to specify where it happened
+ * `EVBUFFER_ERROR` - Marks error condition (need to look at 'errno' for error.. not exposed yet)
+ * `EVBUFFER_TIMEOUT` - Marks activity timeout
+ * `EVBUFFER_EOF` - Marks disconnection/end-of-file condition
+
+## bufferevent.new
+* Input: `(fd, read, write, error)`
+ * `fd` - File descriptor to watch
+ * `read` - (may be nil) - callback to call when data in buffer is above the low watermark
+ * `write` - (may be nil) - callback to call when the output buffer contains less data than the low watermark
+ * `error` - callback to call when there is an erroneous condition
+
+## bufferevent (__gc)
+* Releases the bufferevent
+ * Disconnects event buffers since they were owned by the bufferevent object in 'C' land
+ * Disconnects all references so that any erroneous callbacks don't cause failures
+
+## bufferevent:get_read
+* Obtains the input buffer associated w/ the bufferevent
+
+## 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
+
+## bufferevent:get_read_watermarks
+* Output: `low, high`
+* See `set_read_watermarks`
+
+## bufferevent:get_write_watermarks
+* Output: `low, high`
+* See `set_write_watermarks`
+
+## bufferevent:set_timeouts
+* Sets timeouts for the bufferevent's events
+* Input: `(read, write)`
+ * `read` - Read readiness timeout
+ * `write` - Write readiness timeout
+
+## bufferevent:get_timeouts
+* Output: `read, write`
+* See `set_timeouts`
+
+## bufferevent:enable/disable
+* Input: `event flag`
+ * `event flag` - `EV_READ`, `EV_WRITE`, or `EV_READ|EV_WRITE`
+* Enables/Disables events from being triggered in the next round (some events may get triggered after disable is called)
diff --git a/doc/modules/luaevent.core.mdwn b/doc/modules/luaevent.core.mdwn
new file mode 100644
index 0000000..6c7b112
--- /dev/null
+++ b/doc/modules/luaevent.core.mdwn
@@ -0,0 +1,67 @@
+----
+Constants:
+
+* `LEAVE` - When returned will cause event callback to be cancelled
+* `EV_READ`
+ * Marks read readiness/event capture.
+ * Read readiness can also mean that an 'accept' operation will succeed, or
+ a disconnection on the other end is detected (read will return nothing).
+* `EV_WRITE`
+ * Marks write readiness/event capture.
+ * Can also mark the successful completion of a non-blocking connect
+ if `SO_ERROR`@`SOL_SOCKET` is zero.
+* `EV_SIGNAL`
+ * Marks signal received/event capture
+* `EV_TIMEOUT`
+ * Timeout occurred while waiting for an event
+* `EV_PERSIST`
+ * Marks an event as persistent and not one-shot
+* `EV_*`
+ * Can be OR'd together to capture multiple events that make sense.
+ (Should not OR `EV_READ`/`EV_WRITE` with `EV_SIGNAL`)
+ * Can be received OR'd together.
+ For example: `EV_READ` | `EV_TIMEOUT` means that a timeout
+ occurred while waiting for a read event.
+* `EVBUFFER_READ`
+ * Marks that the input buffer has data available > low watermark
+* `EVBUFFER_WRITE`
+ * Marks that the output buffer level is below low watermark
+* `EVBUFFER_EOF`
+ * Received tagged with either read/write based on location received in the error callback
+* `EVBUFFER_ERROR`
+ * An error occurred (tagged w/ either read/write) and the error is in `errno`
+* `EVBUFFER_TIMEOUT`
+ * A timeout occurred (tagged w/ either read/write)
+
+Functions:
+
+[[toc levels=1]]
+
+## luaevent.core.new
+* Allocates a new event 'core' (`event base`)
+
+## event_callback fn
+* Input: `(event)`
+* Output: `(newEvent, [newTimeout])`
+ * `newEvent` - New event to register, typically `LEAVE`, `EV_READ`, `EV_WRITE`, or `EV_READ`|`EV_WRITE`
+ * `newTimeout` - New timeout value to use
+
+## core:addevent
+* Adds a new event to the eventloop
+* Input: `(fd, event, event_callback, [timeout])`
+ * `fd` - File descriptor to read from / or NIL for pure timeout event
+ * `event` - `EV_*` flagset to mark what events to capture
+ * `EV_SIGNAL` and `EV_PERSIST` is unavailable currently
+ * `EV_PERSIST` is used internally.
+ * `event_callback` - Callback to call... (see above)
+ * `timeout` - Time in seconds to timeout (decimal values supported)
+* Output: `event_callback` object
+ * Has a `close` and `__gc` FN which will erase the callback,
+ so preserve this until done.
+
+## core:loop
+* Begins the event loop and doesn't return until there are no events left
+
+## core:close (__gc)
+* Closes the event base
+* Do not allow this to be called while `core:loop` is running
diff --git a/doc/modules/luaevent.mdwn b/doc/modules/luaevent.mdwn
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/doc/modules/luaevent.mdwn