Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | toralf.wittner@gmail.com |
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.
- data Data
- data Callback
- data EventLoop
- type CallbackFn = Device -> Event Data -> IO ()
- type EventMap = [(EventType, CallbackFn)]
- createEventLoop :: Size -> IO EventLoop
- stopEventLoop :: EventLoop -> IO ()
- addCallback :: EventLoop -> Fd -> EventMap -> IO Callback
- removeCallback :: EventLoop -> Callback -> IO ()
- reEnableCallback :: Device -> Data -> Descriptor Data -> IO ()
- closeEvents :: EventType
Documentation
type EventMap = [(EventType, CallbackFn)]Source
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.
closeEvents :: EventTypeSource
A combination of peerCloseEvent
, errorEvent
, hangupEvent
.