Constants:
LEAVE
- When returned will cause event callback to be cancelledEV_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
withEV_SIGNAL
) - Can be received OR'd together.
For example:
EV_READ
|EV_TIMEOUT
means that a timeout occurred while waiting for a read event.
- Can be OR'd together to capture multiple events that make sense.
(Should not OR
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
- An error occurred (tagged w/ either read/write) and the error is in
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, typicallyLEAVE
,EV_READ
,EV_WRITE
, orEV_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 eventevent
-EV_*
flagset to mark what events to captureEV_SIGNAL
andEV_PERSIST
is unavailable currentlyEV_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.
- Has a
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