arsd.eventloop

crappy event loop for linux

Members

Enums

FileEvents
enum FileEvents

If you add a file to the event loop, which events are you interested in?

Functions

addFileEventListeners
void addFileEventListeners(T t)

To add listeners for file events on a specific file dispatcher, use this. See FileEventDispatcher.addFile for the parameters

addFileToLoop
void addFileToLoop(OsFileHandle fd, int events, bool edgeTriggered = true)

Adds a file handle to the event loop. When the handle has data available to read (if events & FileEvents.read) or write (if events & FileEvents.write), a message FileReadyToRead and/or FileReadyToWrite will be dispatched.

addListener
void addListener(T t)

Adds an event listener. Event listeners must be functions that take exactly one argument.

addOnIdle
void addOnIdle(T t)

Calls this function once every time the event system is idle

clearTimeout
void clearTimeout(TimerHandle handle)

Clears a timer

exit
void exit()

Sends an exit event to the loop. The loop will break when it sees this event, ignoring any events after that point.

loop
void loop()

Runs the loop, dispatching events to registered listeners as they come in

openNewEventPipes
void openNewEventPipes()

you generally won't want to call this, but if you fork() and then try to use the thing without exec(), you might want new pipes so the events don't get mixed up.

removeFileEventListeners
void removeFileEventListeners(OsFileHandle handle)

Removes the file from event handling

removeListener
bool removeListener(T t)

Removes an event listener. Returns true if the event was actually found.

removeOnIdle
void removeOnIdle(T t)

Removes an idle handler (added with addOnIdle)

send
void send(T t)

Send a message to the event loop

sendSync
void sendSync(T t)

Sends a message to the listeners immediately, bypassing the event loop

setInterval
TimerHandle setInterval(T t, int msecsInterval)

Sets a continuously firing interval. It will call the function as close to the interval as it can, but it won't let triggers stack up.

setTimeout
TimerHandle setTimeout(T t, int msecsWait, int count = 1)

Sets a timer, one-shot by default. Count tells how many times the timer will fire. Set to zero for a continuously firing timer

Structs

FileError
struct FileError

This is a low level event that is dispatched when a listened file (see: addFileToLoop) has an error

FileEventDispatcher
struct FileEventDispatcher

Since the lowest level event for files only allows one handler, but can send events that require a variety of different responses, the FileEventDispatcher is available to make this easer.

FileHup
struct FileHup

This is a low level event that is dispatched when a listened file (see: addFileToLoop) has a hang up event

FileReadyToRead
struct FileReadyToRead

This is a low level event that is dispatched when a listened file (see: addFileToLoop) is ready to be read You should read as much as possible without blocking from the file now, as a future event may not be fired for left over data

FileReadyToWrite
struct FileReadyToWrite

This is a low level event that is dispatched when a listened file (see: addFileToLoop) is ready to be written to

TimerHandle
struct TimerHandle

An opaque type to reference an active timer

Templates

isValidEventListener
template isValidEventListener(T)

Valid event listeners must be callable and take exactly one argument. The type of argument determines the type of event.

Suggestion Box / Bug Report