graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.Extended

Synopsis

Documentation

sleep :: DiffTime -> IO () Source #

Like threadDelay, but takes a DiffTime instead of an Int microseconds.

NOTE: you cannot simply replace e.g. threadDelay 1000 with sleep 1000 since those literals have different meanings!

forkImmortal Source #

Arguments

:: ForkableMonadIO m 
=> String

A label describing this thread's function (see labelThread).

-> Logger Hasura 
-> m Void

An IO action we expect never to return normally. This will have the type signature ':: m a' (see e.g. the type of forever).

-> m Thread

A handle for the forked thread. See Control.Immortal.

Note: Please consider using forkManagedT instead to ensure reliable resource cleanup.

newtype ThreadShutdown m Source #

ThreadShutdown is a newtype wrapper over an action which is intended to execute when a thread's shutdown is initiated before killing the thread

Constructors

ThreadShutdown 

Fields

forkManagedT :: ForkableMonadIO m => String -> Logger Hasura -> m Void -> ManagedT m Thread Source #

This function pairs a call to forkImmortal with a finalizer which stops the immortal thread.

data Forever m Source #

The Forever type defines an infinite looping monadic action (like m void), but allows the caller to control the recursion or insert code before each iteration. The a is the initial argument, and subsequent iterations will be fed the argument returned by the previous one. See forkManagedTWithGracefulShutdown to see how it's used

Constructors

forall a. Forever a (a -> m a) 

forkManagedTWithGracefulShutdown :: ForkableMonadIO m => String -> Logger Hasura -> ThreadShutdown m -> m (Forever m) -> ManagedT m Thread Source #

forkManagedTWithGracefulShutdown is an extension of the forkManagedT function this function also attempts to gracefully shutdown the thread. This function accepts a `m (Forever m)` argument. The Forever type contains a function and an argument to the function. The function supplied will be run repeatedly until shutdown is initiated. The response of the function will be the argument to the next iteration.

For reference, this function is used to run the async actions processor. Check asyncActionsProcessor

type ForkableMonadIO m = (MonadIO m, MonadBaseControl IO m, Forall (Pure m)) Source #

Like MonadIO but constrained to stacks in which forking a new thread is reasonable/safe. In particular StateT causes problems.

This is the constraint you can use for functions that call async, or immortal.

forConcurrentlyEIO :: (MonadIO m, MonadError e m) => Int -> [a] -> (a -> ExceptT e IO b) -> m [b] Source #

A somewhat wonky function for parallelizing for xs f where f is (MonadIO m, MonadError e m). This is equivalent to for xs f modulo the IO effects (i.e. when the IO has no real side effects we care about).

This also takes a chunkSize argument so you can manipulate the amount of work given to each thread.

concurrentlyEIO :: (MonadIO m, MonadError e m) => ExceptT e IO a -> ExceptT e IO b -> m (a, b) Source #