Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
This module provides scalable event notification for file descriptors and timeouts.
This module should be considered GHC internal.
- ---------------------------------------------------------------------------
- data EventManager
- data TimerManager
- getSystemEventManager :: IO (Maybe EventManager)
- new :: Bool -> IO EventManager
- getSystemTimerManager :: IO TimerManager
- 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
- closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO ()
- type TimeoutCallback = IO ()
- data TimeoutKey
- registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey
- updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO ()
- unregisterTimeout :: TimerManager -> TimeoutKey -> IO ()
Types
data EventManager Source
The event manager state.
data TimerManager Source
The event manager state.
Creation
new :: Bool -> IO EventManager Source
Create a new event manager.
Registering interest in I/O events
type IOCallback = FdKey -> Event -> IO () Source
Callback invoked on I/O events.
registerFd :: EventManager -> IOCallback -> Fd -> Event -> IO FdKey Source
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 Bool Source
Drop a previous file descriptor registration, without waking the event manager thread. The return value indicates whether the event manager ought to be woken.
closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO () Source
Close a file descriptor in a race-safe way.
Registering interest in timeout events
type TimeoutCallback = IO () Source
Callback invoked on timeout events.
registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey Source
Register a timeout in the given number of microseconds. The
returned TimeoutKey
can be used to later unregister or update the
timeout. The timeout is automatically unregistered after the given
time has passed.
updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO () Source
Update an active timeout to fire in the given number of microseconds.
unregisterTimeout :: TimerManager -> TimeoutKey -> IO () Source
Unregister an active timeout.