ConcurrentUtils-0.4.1.0: Concurrent utilities

Safe HaskellNone
LanguageHaskell98

Control.CUtils.Deadlock

Description

Automatic deadlock prevention.

Automatic deadlock detection is inefficient, and computations cannot be rolled back or aborted in general.

Instead, we prevent deadlocks before they happen.

Synopsis

Documentation

data Res t u where Source

The Res arrow.

Computations are built with these constructors (and the arrow interface). The implementation guarantees progress provided: * Pieces of the arrow that hold locks are finitely examinable, * threads are programmed to eventually release a lock they hold, * locks are the only source of deadlock, * and all locks are used only with the Acq and Rel ctors (which acquire and release a lock resp.).

Constructors

Lift :: Kleisli IO t v -> Res v u -> Res t u 
Acq :: MVar () -> Res t u -> Res t u 
Rel :: MVar () -> Res t u -> Res t u 
Fork :: Res t () -> Res t u -> Res t u 
Plus :: Res t v -> Res u v -> Res (Either t u) v 
Id :: Res t t 

run :: Res t u -> t -> IO u Source

Use this to run computations built in the Res arrow.

lft :: IO a -> Res v u -> Res v u Source