epoll-0.2.2: epoll bindings

Portabilitynon-portable
Stabilityexperimental
Maintainertoralf.wittner@gmail.com

System.Linux.Epoll.EventLoop

Description

EventLoop's can be used to get notified when certain events occur on a file descriptor. One can add callback functions for any EventType combination.

Synopsis

Documentation

data Callback Source

Abstract data type holding bookeeping info.

data EventLoop Source

Abstract data type.

type CallbackFn = Device -> Event Data -> IO ()Source

Callback function type

createEventLoop :: Size -> IO EventLoopSource

Create one event loop which handles up to Size events per call to epoll's wait. An event loop runs until stopEventLoop is invoked, calling wait with a max timeout of 500ms before it waits again.

stopEventLoop :: EventLoop -> IO ()Source

Terminates the event loop and cleans resources. Note that one can only remove callbacks from an eventloop while it is running, so make sure you call this function after all removeCallback calls.

addCallback :: EventLoop -> Fd -> EventMap -> IO CallbackSource

Adds a callback for the given file descriptor to this event loop. The event map specifies for each event type which function to call. event types might be combined using combineEvents.

removeCallback :: EventLoop -> Callback -> IO ()Source

Removes the callback obtained from addCallback from this event loop. Note that you must not call stopEventLoop before invoking this function.

reEnableCallback :: Device -> Data -> Descriptor Data -> IO ()Source

In case you use oneShotEvent you can re-enable a callback after the event occured. Otherwise no further events will be reported. Cf. epoll(7) for details.