doc/modules/luaevent.core.mdwn

changeset 52
48def27d8ddd
parent 51
a11824050314
equal deleted inserted replaced
51:a11824050314 52:48def27d8ddd
21 (Should not OR `EV_READ`/`EV_WRITE` with `EV_SIGNAL`) 21 (Should not OR `EV_READ`/`EV_WRITE` with `EV_SIGNAL`)
22 * Can be received OR'd together. 22 * Can be received OR'd together.
23 For example: `EV_READ` | `EV_TIMEOUT` means that a timeout 23 For example: `EV_READ` | `EV_TIMEOUT` means that a timeout
24 occurred while waiting for a read event. 24 occurred while waiting for a read event.
25 * `EVBUFFER_READ` 25 * `EVBUFFER_READ`
26 * Marks that the input buffer has data available > low watermark
26 * `EVBUFFER_WRITE` 27 * `EVBUFFER_WRITE`
28 * Marks that the output buffer level is below low watermark
27 * `EVBUFFER_EOF` 29 * `EVBUFFER_EOF`
30 * Received tagged with either read/write based on location received in the error callback
28 * `EVBUFFER_ERROR` 31 * `EVBUFFER_ERROR`
32 * An error occurred (tagged w/ either read/write) and the error is in `errno`
29 * `EVBUFFER_TIMEOUT` 33 * `EVBUFFER_TIMEOUT`
34 * A timeout occurred (tagged w/ either read/write)
30 35
31 Functions: 36 Functions:
32 37
33 [[toc levels=1]] 38 [[toc levels=1]]
34 39
40 ## luaevent.core.new
41 * Allocates a new event 'core' (`event base`)
42
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
48
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.
61
62 ## core:loop
63 * Begins the event loop and doesn't return until there are no events left
64
65 ## core:close (__gc)
66 * Closes the event base
67 * Do not allow this to be called while `core:loop` is running

mercurial