Delay the thread by n microseconds.
Modulehedgehog-extras-0.10.1.0Haskell2010
Hedgehog.Extras.Test.Concurrent
This modules provides concurrency abstractions for hedgehog tests. Using "lifted-base" one can execute expensive test actions concurrently.
For example, the actions invoked inside mapConcurrently_ are invoked in the same MonadTest as the outer monad of mapConcurrently_.
import qualified Hedgehog.Extras.Test.Concurrent as H
setUpEnvironment = H.mapConcurrently_ id
[ H.threadDelay 100 >> pure 1
, H.threadDelay 200 >> pure 2
, H.threadDelay 300 >> pure 3
]
Warning: Do not use this module for running concurrent checks! The MonadBaseControl instance does not
aggregate effects for PropertyT. Consider the following code:
LA.mapConcurrently_ id
[ do
H.note_ "FAIL1"
success
, do
IO.threadDelay 1_000_000
H.note_ "FAIL2"
failure
, do
H.note_ "FAIL3"
failure
]
Executing this code will give you the following output in the test report:
66 ┃ LA.mapConcurrently_ id
67 ┃ [ do
68 ┃ H.note_ "FAIL1"
┃ │ FAIL1
69 ┃ success
70 ┃ , do
71 ┃ IO.threadDelay 1_000_000
72 ┃ H.note_ "FAIL2"
┃ │ FAIL2
73 ┃ failure
┃ ^^^^^^^
74 ┃ , do
75 ┃ H.note_ "FAIL3"
76 ┃ failure
77 ┃ ]
Please note that only FAIL1 and FAIL2 annotations were reported - FAIL3 annotation and the failure
below was swallowed without any information.
Don't use concurrency abstractions from this module, when you need to aggregate and report failures!
- 5 types
- 69 values
- Packagehedgehog-extras-0.10.1.0
- Exports74
- LanguageHaskell2010
- LicenceApache-2.0
- SourceConcurrent.hs
asyncRegister_ :: (HasCallStack, MonadTest m, MonadResource m, MonadCatch m)=> IO aAction to run in background
-> m ()
Runs an action in background, and registers its cancellation to MonadResource.
Re-exports of concurrency abstractions from lifted-base
72 declarationsCompare two Asyncs that may have different types by their ThreadId.
A version of poll that can be used inside an STM transaction.
A version of waitAnyCatch that can be used inside an STM transaction.
A version of waitAny that can be used inside an STM transaction.
A version of waitBoth that can be used inside an STM transaction.
A version of waitCatch that can be used inside an STM transaction.
A version of waitEitherCatch that can be used inside an STM transaction.
A version of waitEither that can be used inside an STM transaction.
A version of waitEither_ that can be used inside an STM transaction.
A version of wait that can be used inside an STM transaction.
Generalized version of async.
Generalized version of asyncBound.
Generalized version of asyncOn.
Generalized version of asyncOnWithUnmask.
Generalized version of asyncWithUnmask.
Generalized version of cancel.
Generalized version of cancelWith.
Generalized version of concurrently.
Generalized version of concurrently_.
Generalized version of forConcurrently.
Generalized version of forConcurrently_.
Generalized version of link.
Generalized version of link2.
Generalized version of mapConcurrently.
Generalized version of mapConcurrently_.
Generalized version of poll.
Generalized version of race.
Generalized version of race_.
NOTE: This function discards the monadic effects besides IO in the forked computation.
Generalized version of replicateConcurrently.
Generalized version of replicateConcurrently_.
Generalized version of uninterruptibleCancel.
Generalized version of wait.
Generalized version of waitAny.
Generalized version of waitAnyCancel.
Generalized version of waitAnyCatch.
Generalized version of waitAnyCatchCancel.
Generalized version of waitBoth.
Generalized version of waitCatch.
Generalized version of waitEither.
Generalized version of waitEitherCancel.
Generalized version of waitEitherCatch.
Generalized version of waitEitherCatchCancel.
Generalized version of waitEither_.
NOTE: This function discards the monadic effects besides IO in the forked computation.
Generalized version of withAsync.
Generalized version of withAsyncBound.
Generalized version of withAsyncOn.
Generalized version of withAsyncOnWithUnmask.
Generalized version of withAsyncWithUnmask.
Instances4Functor, Eq, Ord, Hashable
The exception thrown by cancel to terminate a thread.
Instances3Eq, Show, Exception
Eq AsyncCancelledDefined in async-2.2.6 · Control.Concurrent.Async.InternalShow AsyncCancelledDefined in async-2.2.6 · Control.Concurrent.Async.InternalException AsyncCancelledDefined in async-2.2.6 · Control.Concurrent.Async.Internal
Constructors
forall a. ExceptionInLinkedThread (Async a) SomeException
Instances2Show, Exception
Show ExceptionInLinkedThreadDefined in async-2.2.6 · Control.Concurrent.Async.InternalException ExceptionInLinkedThreadDefined in async-2.2.6 · Control.Concurrent.Async.Internal
Generalized version of Concurrently.
A value of type Concurrently m a is an IO-based operation that can be
composed with other Concurrently values, using the Applicative and
Alternative instances.
Calling runConcurrently on a value of type Concurrently m a will
execute the IO-based lifted operations it contains concurrently, before
delivering the result of type a.
For example
(page1, page2, page3) <- runConcurrently $ (,,)
<$> Concurrently (getURL "url1")
<*> Concurrently (getURL "url2")
<*> Concurrently (getURL "url3")
Constructors
ConcurrentlyrunConcurrently :: m a
Instances5Functor, Applicative, Alternative, Semigroup, Monoid
Functor m => Functor (Concurrently m)Defined in lifted-async-0.11.0 · Control.Concurrent.Async.LiftedMonadBaseControl IO m => Applicative (Concurrently m)Defined in lifted-async-0.11.0 · Control.Concurrent.Async.LiftedMonadBaseControl IO m => Alternative (Concurrently m)Defined in lifted-async-0.11.0 · Control.Concurrent.Async.Lifted(MonadBaseControl IO m, Semigroup a) => Semigroup (Concurrently m a)Defined in lifted-async-0.11.0 · Control.Concurrent.Async.Lifted(MonadBaseControl IO m, Semigroup a, Monoid a) => Monoid (Concurrently m a)Defined in lifted-async-0.11.0 · Control.Concurrent.Async.Lifted
Generalized version of isEmptyMVar.
Generalized version of mkWeakMVar.
Note any monadic side effects in m of the "finalizer" computation are
discarded.
Generalized version of modifyMVar.
Generalized version of modifyMVarMasked.
Generalized version of modifyMVarMasked_.
Generalized version of modifyMVar_.
Generalized version of newEmptyMVar.
Generalized version of newMVar.
Generalized version of putMVar.
Generalized version of readMVar.
Generalized version of swapMVar.
Generalized version of takeMVar.
Generalized version of tryPutMVar.
Generalized version of tryReadMVar.
Generalized version of tryTakeMVar.
Generalized version of withMVar.
Generalized version of withMVarMasked.
An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.
Instances3NFData1, Eq, NFData
Generalized version of timeout.
Note that when the given computation times out any side effects of m are
discarded. When the computation completes within the given time the
side-effects are restored on return.