| Safe Haskell | Trustworthy | 
|---|---|
| Language | Haskell2010 | 
GHC.Event
Description
This module provides scalable event notification for file descriptors and timeouts.
This module should be considered GHC internal.
- ---------------------------------------------------------------------------
Synopsis
- data EventManager
- data TimerManager
- getSystemEventManager :: IO (Maybe EventManager)
- new :: IO EventManager
- getSystemTimerManager :: IO TimerManager
- data Event
- evtRead :: Event
- evtWrite :: Event
- type IOCallback = FdKey -> Event -> IO ()
- data FdKey
- data Lifetime
- registerFd :: EventManager -> IOCallback -> Fd -> Event -> Lifetime -> IO FdKey
- 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 #
The event manager state.
data TimerManager #
The event manager state.
Creation
new :: IO EventManager #
Create a new event manager.
Registering interest in I/O events
An I/O event.
type IOCallback = FdKey -> Event -> IO () #
Callback invoked on I/O events.
A file descriptor registration cookie.
The lifetime of an event registration.
Since: base-4.8.1.0
Constructors
| OneShot | the registration will be active for only one event | 
| MultiShot | the registration will trigger multiple times | 
registerFd :: EventManager -> IOCallback -> Fd -> Event -> Lifetime -> IO FdKey #
registerFd mgr cb fd evs lt registers interest in the events evs
 on the file descriptor fd for lifetime lt. cb is called for
 each event that occurs.  Returns a cookie that can be handed to
 unregisterFd.
unregisterFd :: EventManager -> FdKey -> IO () #
Drop a previous file descriptor registration.
unregisterFd_ :: EventManager -> FdKey -> IO Bool #
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 () #
Close a file descriptor in a race-safe way.
Registering interest in timeout events
type TimeoutCallback = IO () #
Warning: since the TimeoutCallback is called from the I/O manager, it must
 not throw an exception or block for a long period of time.  In particular,
 be wary of throwTo and killThread:
 if the target thread is making a foreign call, these functions will block
 until the call completes.
data TimeoutKey #
A timeout registration cookie.
Instances
| Eq TimeoutKey # | |
| Defined in GHC.Event.TimeOut Methods (==) :: TimeoutKey -> TimeoutKey -> Bool Source # (/=) :: TimeoutKey -> TimeoutKey -> Bool Source # | |
| Ord TimeoutKey # | |
| Defined in GHC.Event.TimeOut Methods compare :: TimeoutKey -> TimeoutKey -> Ordering Source # (<) :: TimeoutKey -> TimeoutKey -> Bool Source # (<=) :: TimeoutKey -> TimeoutKey -> Bool Source # (>) :: TimeoutKey -> TimeoutKey -> Bool Source # (>=) :: TimeoutKey -> TimeoutKey -> Bool Source # max :: TimeoutKey -> TimeoutKey -> TimeoutKey Source # min :: TimeoutKey -> TimeoutKey -> TimeoutKey Source # | |
registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey #
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 () #
Update an active timeout to fire in the given number of microseconds.
unregisterTimeout :: TimerManager -> TimeoutKey -> IO () #
Unregister an active timeout.