unliftio-0.2.13: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe Haskell | None
Language | Haskell2010

UnliftIO.Concurrent

Contents

- Concurrent Haskell
- Basic concurrency operations
  - Threads with affinity
- Scheduling
  - Waiting
- Communication abstractions
- Bound Threads
- Weak references to ThreadIds

Description

Unlifted Control.Concurrent.

This module is not reexported by UnliftIO, use it only if UnliftIO.Async is not enough.

Since: 0.1.1.0

Synopsis

- data ThreadId
- myThreadId :: MonadIO m => m ThreadId
- forkIO :: MonadUnliftIO m => m () -> m ThreadId
- forkWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId
- forkIOWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId
- forkFinally :: MonadUnliftIO m => m a -> (Either SomeException a -> m ()) -> m ThreadId
- killThread :: MonadIO m => ThreadId -> m ()
- throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m ()
- forkOn :: MonadUnliftIO m => Int -> m () -> m ThreadId
- forkOnWithUnmask :: MonadUnliftIO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId
- getNumCapabilities :: MonadIO m => m Int
- setNumCapabilities :: MonadIO m => Int -> m ()
- threadCapability :: MonadIO m => ThreadId -> m (Int, Bool)
- yield :: MonadIO m => m ()
- threadDelay :: MonadIO m => Int -> m ()
- threadWaitRead :: MonadIO m => Fd -> m ()
- threadWaitWrite :: MonadIO m => Fd -> m ()
- module UnliftIO.MVar
- module UnliftIO.Chan
- rtsSupportsBoundThreads :: Bool
- forkOS :: MonadUnliftIO m => m () -> m ThreadId
- isCurrentThreadBound :: MonadIO m => m Bool
- runInBoundThread :: MonadUnliftIO m => m a -> m a
- runInUnboundThread :: MonadUnliftIO m => m a -> m a
- mkWeakThreadId :: MonadIO m => ThreadId -> m (Weak ThreadId)

# Concurrent Haskell

data ThreadId #

#### Instances

Instances details

Eq ThreadId |
Instance details Defined in GHC.Conc.Sync Methods (==) :: ThreadId -> ThreadId -> Bool (/=) :: ThreadId -> ThreadId -> Bool
Ord ThreadId |
Instance details Defined in GHC.Conc.Sync Methods compare :: ThreadId -> ThreadId -> Ordering (<) :: ThreadId -> ThreadId -> Bool (<=) :: ThreadId -> ThreadId -> Bool (>) :: ThreadId -> ThreadId -> Bool (>=) :: ThreadId -> ThreadId -> Bool max :: ThreadId -> ThreadId -> ThreadId min :: ThreadId -> ThreadId -> ThreadId
Show ThreadId |
Instance details Defined in GHC.Conc.Sync Methods showsPrec :: Int -> ThreadId -> ShowS show :: ThreadId -> String showList :: [ThreadId] -> ShowS
NFData ThreadId |
Instance details Defined in Control.DeepSeq Methods rnf :: ThreadId -> ()
Hashable ThreadId |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ThreadId -> Int hash :: ThreadId -> Int

# Basic concurrency operations

myThreadId :: MonadIO m => m ThreadId Source #

Lifted version of `myThreadId`.

Since: 0.1.1.0

forkIO :: MonadUnliftIO m => m () -> m ThreadId Source #

Unlifted version of `forkIO`.

Since: 0.1.1.0

forkWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId Source #

Deprecated: forkWithUnmask has been renamed to forkIOWithUnmask

Please use `forkIOWithUnmask` instead. This function has been deprecated in release 0.2.11 and will be removed in the next major release.

Since: 0.1.1.0

forkIOWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId Source #

Unlifted version of `forkIOWithUnmask`.

Since: 0.2.11

forkFinally :: MonadUnliftIO m => m a -> (Either SomeException a -> m ()) -> m ThreadId Source #

Unlifted version of `forkFinally`.

Since: 0.1.1.0

killThread :: MonadIO m => ThreadId -> m () Source #

Lifted version of `killThread`.

Since: 0.1.1.0

throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m () Source #

Throw an asynchronous exception to another thread.

Synchronously typed exceptions will be wrapped into an `AsyncExceptionWrapper`, see https://github.com/fpco/safe-exceptions#determining-sync-vs-async.

It's usually a better idea to use the UnliftIO.Async module, see https://github.com/fpco/safe-exceptions#quickstart.

Since: 0.1.0.0

## Threads with affinity

forkOn :: MonadUnliftIO m => Int -> m () -> m ThreadId Source #

Unlifted version of `forkOn`.

Since: 0.1.1.0

forkOnWithUnmask :: MonadUnliftIO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId Source #

Unlifted version of `forkOnWithUnmask`.

Since: 0.1.1.0

getNumCapabilities :: MonadIO m => m Int Source #

Lifted version of `getNumCapabilities`.

Since: 0.1.1.0

setNumCapabilities :: MonadIO m => Int -> m () Source #

Lifted version of `setNumCapabilities`.

Since: 0.1.1.0

threadCapability :: MonadIO m => ThreadId -> m (Int, Bool) Source #

Lifted version of `threadCapability`.

Since: 0.1.1.0

# Scheduling

yield :: MonadIO m => m () Source #

Lifted version of `yield`.

Since: 0.1.1.0

## Waiting

threadDelay :: MonadIO m => Int -> m () Source #

Lifted version of `threadDelay`.

Since: 0.1.1.0

threadWaitRead :: MonadIO m => Fd -> m () Source #

Lifted version of `threadWaitRead`.

Since: 0.1.1.0

threadWaitWrite :: MonadIO m => Fd -> m () Source #

Lifted version of `threadWaitWrite`.

Since: 0.1.1.0

# Communication abstractions

module UnliftIO.MVar

module UnliftIO.Chan

# Bound Threads

rtsSupportsBoundThreads :: Bool #

forkOS :: MonadUnliftIO m => m () -> m ThreadId Source #

Unflifted version of `forkOS`.

Since: 0.1.1.0

isCurrentThreadBound :: MonadIO m => m Bool Source #

Lifted version of `isCurrentThreadBound`.

Since: 0.1.1.0

runInBoundThread :: MonadUnliftIO m => m a -> m a Source #

Unlifted version of `runInBoundThread`.

Since: 0.1.1.0

runInUnboundThread :: MonadUnliftIO m => m a -> m a Source #

Unlifted version of `runInUnboundThread`.

Since: 0.1.1.0

# Weak references to ThreadIds

mkWeakThreadId :: MonadIO m => ThreadId -> m (Weak ThreadId) Source #

Lifted version of `mkWeakThreadId`.

Since: 0.1.1.0