Add base:method() to return string identifying the current libevent backend in use
[luaevent.git] / doc / modules / luaevent.core.mdwn
blob6c7b1125026e58c393573d8958284b27a7d63c22
1 ----
2 Constants:
4 * `LEAVE` - When returned will cause event callback to be cancelled
5 * `EV_READ`
6         * Marks read readiness/event capture.
7         * Read readiness can also mean that an 'accept' operation will succeed, or
8           a disconnection on the other end is detected (read will return nothing).
9 * `EV_WRITE`
10         * Marks write readiness/event capture.
11         * Can also mark the successful completion of a non-blocking connect
12           if `SO_ERROR`@`SOL_SOCKET` is zero.
13 * `EV_SIGNAL`
14         * Marks signal received/event capture
15 * `EV_TIMEOUT`
16         * Timeout occurred while waiting for an event
17 * `EV_PERSIST`
18         * Marks an event as persistent and not one-shot
19 * `EV_*`
20         * Can be OR'd together to capture multiple events that make sense.
21           (Should not OR `EV_READ`/`EV_WRITE` with `EV_SIGNAL`)
22         * Can be received OR'd together.
23           For example: `EV_READ` | `EV_TIMEOUT` means that a timeout
24           occurred while waiting for a read event.
25 * `EVBUFFER_READ`
26         * Marks that the input buffer has data available > low watermark
27 * `EVBUFFER_WRITE`
28         * Marks that the output buffer level is below low watermark
29 * `EVBUFFER_EOF`
30         * Received tagged with either read/write based on location received in the error callback
31 * `EVBUFFER_ERROR`
32         * An error occurred (tagged w/ either read/write) and the error is in `errno`
33 * `EVBUFFER_TIMEOUT`
34         * A timeout occurred (tagged w/ either read/write)
36 Functions:
38 [[toc levels=1]]
40 ## luaevent.core.new
41 * Allocates a new event 'core' (`event base`)
43 ## event_callback fn
44 * Input: `(event)`
45 * Output: `(newEvent, [newTimeout])`
46         * `newEvent` - New event to register, typically `LEAVE`, `EV_READ`, `EV_WRITE`, or `EV_READ`|`EV_WRITE`
47         * `newTimeout` - New timeout value to use
49 ## core:addevent
50 * Adds a new event to the eventloop
51 * Input: `(fd, event, event_callback, [timeout])`
52         * `fd` - File descriptor to read from / or NIL for pure timeout event
53         * `event` - `EV_*` flagset to mark what events to capture
54                 * `EV_SIGNAL` and `EV_PERSIST` is unavailable currently
55                 * `EV_PERSIST` is used internally.
56         * `event_callback` - Callback to call... (see above)
57         * `timeout` - Time in seconds to timeout (decimal values supported)
58 * Output: `event_callback` object
59         * Has a `close` and `__gc` FN which will erase the callback, 
60           so preserve this until done.
62 ## core:loop
63 * Begins the event loop and doesn't return until there are no events left
65 ## core:close (__gc)
66 * Closes the event base
67 * Do not allow this to be called while `core:loop` is running