- data EventManager
- new :: IO EventManager
- loop :: EventManager -> IO ()
- step :: EventManager -> TimeoutQueue -> IO (Bool, TimeoutQueue)
- shutdown :: EventManager -> IO ()
- data Event
- evtRead :: Event
- evtWrite :: Event
- type IOCallback = FdKey -> Event -> IO ()
- data FdKey
- registerFd :: EventManager -> IOCallback -> Fd -> Event -> IO FdKey
- registerFd_ :: EventManager -> IOCallback -> Fd -> Event -> IO (FdKey, Bool)
- unregisterFd :: EventManager -> FdKey -> IO ()
- unregisterFd_ :: EventManager -> FdKey -> IO Bool
- fdWasClosed :: EventManager -> Fd -> IO ()
- type TimeoutCallback = IO ()
- data TimeoutKey
- registerTimeout :: EventManager -> Int -> TimeoutCallback -> IO TimeoutKey
- updateTimeout :: EventManager -> TimeoutKey -> Int -> IO ()
- unregisterTimeout :: EventManager -> TimeoutKey -> IO ()
Types
data EventManager Source
The event manager state.
Creation
Create a new event manager.
Running
loop :: EventManager -> IO ()Source
Start handling events. This function loops until told to stop.
Note: This loop can only be run once per EventManager
, as it
closes all of its control resources when it finishes.
Stepwise running
step :: EventManager -> TimeoutQueue -> IO (Bool, TimeoutQueue)Source
shutdown :: EventManager -> IO ()Source
Asynchronously shuts down the event manager, if running.
Registering interest in I/O events
registerFd :: EventManager -> IOCallback -> Fd -> Event -> IO FdKeySource
registerFd mgr cb fd evs
registers interest in the events evs
on the file descriptor fd
. cb
is called for each event that
occurs. Returns a cookie that can be handed to unregisterFd
.
registerFd_ :: EventManager -> IOCallback -> Fd -> Event -> IO (FdKey, Bool)Source
Register interest in the given events, without waking the event
manager thread. The Bool
return value indicates whether the
event manager ought to be woken.
unregisterFd :: EventManager -> FdKey -> IO ()Source
Drop a previous file descriptor registration.
unregisterFd_ :: EventManager -> FdKey -> IO BoolSource
Drop a previous file descriptor registration, without waking the event manager thread. The return value indicates whether the event manager ought to be woken.
fdWasClosed :: EventManager -> Fd -> IO ()Source
Notify the event manager that a file descriptor has been closed.
Registering interest in timeout events
type TimeoutCallback = IO ()Source
Callback invoked on timeout events.
data TimeoutKey Source
registerTimeout :: EventManager -> Int -> TimeoutCallback -> IO TimeoutKeySource
Register a timeout in the given number of microseconds.
updateTimeout :: EventManager -> TimeoutKey -> Int -> IO ()Source
unregisterTimeout :: EventManager -> TimeoutKey -> IO ()Source