conio
Safe HaskellNone
LanguageGHC2021

ConIO.Race

Synopsis

Race

raceTwo :: IO a -> IO a -> ConIO (Task a) Source #

Race two actions. The slower is canceled.

raceTwoMaybe :: IO (Maybe a) -> IO (Maybe a) -> ConIO (Task (Maybe a)) Source #

Race two actions which may produce results. If one action produces a result, the other one is cancelled. If no actions produce a result, then the resulting task also produces nothing.

raceMany :: Traversable t => t (IO a) -> ConIO (Task a) Source #

Race many actions which may produce results. If one action produces a result, the other ones are cancelled. If no actions produce a result, then the resulting task also produces nothing.

raceManyMaybe :: Traversable t => t (IO (Maybe a)) -> ConIO (Task (Maybe a)) Source #

Race many actions. The slower ones are canceled.

raceTwoTasks :: Task a -> Task a -> ConIO (Task a) Source #

Race two already started Tasks. The slower one is cancelled.

Keep in mind that cancelling the resulting Task will cancel both given Tasks.

raceTwoTasksMaybe :: Task (Maybe a) -> Task (Maybe a) -> ConIO (Task (Maybe a)) Source #

Race already started Tasks and use the first produced Just value. The slower task is cancelled.

Keep in mind that cancelling the resulting Task will cancel both given Tasks.

raceManyTasks :: Traversable t => t (Task a) -> ConIO (Task a) Source #

Race already started Tasks. The slower ones are cancelled.

Keep in mind that cancelling the resulting Task will all given Tasks.

raceManyTasksMaybe :: Traversable t => t (Task (Maybe a)) -> ConIO (Task (Maybe a)) Source #

Race already started Tasks and use the first produced Just value. The slower tasks are cancelled.

Keep in mind that cancelling the resulting Task will all given Tasks.

Timeout

timeout :: Duration -> IO a -> ConIO (Maybe a) Source #

Time out an action.

timeoutTask :: Duration -> Task a -> ConIO (Task (Maybe a)) Source #

Time out a Task, counting the Duration down from the moment that timeoutTask is executed. The total runtime of the Task does not matter.

Waiting

waitDuration :: MonadIO m => Duration -> m () Source #

Waits forever

waitForever :: MonadIO m => m a Source #

Waits forever

Duration

data Duration Source #

Duration is a time span. It is used for waiting and timeouts.

Instances

Instances details
Num Duration Source # 
Instance details

Defined in ConIO.Race

Show Duration Source # 
Instance details

Defined in ConIO.Race

Eq Duration Source # 
Instance details

Defined in ConIO.Race

Ord Duration Source # 
Instance details

Defined in ConIO.Race

fromSeconds :: Word -> Duration Source #

Create a Duration from seconds

fromMilliseconds :: Word -> Duration Source #

Create a Duration from milliseconds

fromMicroseconds :: Word -> Duration Source #

Create a Duration from microseconds