Portability | non-portable (GHC extensions) |
---|---|
Stability | internal |
Maintainer | cvs-ghc@haskell.org |
Basic concurrency stuff.
- ensureIOManagerIsRunning :: IO ()
- threadDelay :: Int -> IO ()
- registerDelay :: Int -> IO (TVar Bool)
- threadWaitRead :: Fd -> IO ()
- threadWaitWrite :: Fd -> IO ()
- closeFdWith :: (Fd -> IO ()) -> Fd -> IO ()
Documentation
Waiting
threadDelay :: Int -> IO ()Source
Suspends the current thread for a given number of microseconds (GHC only).
There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will never continue to run earlier than specified.
registerDelay :: Int -> IO (TVar Bool)Source
Set the value of returned TVar to True after a given number of microseconds. The caveats associated with threadDelay also apply.
threadWaitRead :: Fd -> IO ()Source
Block the current thread until data is available to read on the given file descriptor (GHC only).
This will throw an IOError
if the file descriptor was closed
while this thread was blocked. To safely close a file descriptor
that has been used with threadWaitRead
, use closeFdWith
.
threadWaitWrite :: Fd -> IO ()Source
Block the current thread until data can be written to the given file descriptor (GHC only).
This will throw an IOError
if the file descriptor was closed
while this thread was blocked. To safely close a file descriptor
that has been used with threadWaitWrite
, use closeFdWith
.
:: (Fd -> IO ()) | Low-level action that performs the real close. |
-> Fd | File descriptor to close. |
-> IO () |
Close a file descriptor in a concurrency-safe way (GHC only). If
you are using threadWaitRead
or threadWaitWrite
to perform
blocking I/O, you must use this function to close file
descriptors, or blocked threads may not be woken.
Any threads that are blocked on the file descriptor via
threadWaitRead
or threadWaitWrite
will be unblocked by having
IO exceptions thrown.