-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A wrapping library for waitfree computation.
--
-- A combinator library for asynchronous waitfree computation among
-- forkIO threads.
@package waitfree
@version 0.1.4
module Control.Concurrent.Waitfree
-- | ZeroT is a Thread
data ZeroT
-- | 'SucT t' is a Thread if t is a Thread. The name
-- SucT comes from the successor function.
data SucT t
-- | HNil is the empty IOerSequent
data HNil
-- | 'HCons (K t e)' adds a remote computation in front of a
-- IOerSequent
data HCons e l
-- | an abreviation for HCons
type :*: e l = HCons e l
-- | A value of type 'K t a' represents a remote computation returning
-- a that is performed by a thread t.
data K t a
-- | single creates a IO hypersequent consisting of a single remote
-- computation.
single :: Thread t => (t -> IO a) -> IO (K t a :*: HNil)
-- | An abstract representation of a thread. Threads are actually
-- implemented using forkIO.
class Thread t
t :: Thread t => t
atid :: Thread t => t -> AbstractThreadId
-- | Each Thread type has AbstractThreadId
type AbstractThreadId = Int
-- | comm stands for communication. comm combines two
-- hypersequents with a communicating component from each hypersequent. |
-- 'comm hypersequent1 error1 hypersequent2 error2' where error1
-- and error2 specifies what to do in case of read failure.
comm :: (Thread s, Thread t, HAppend l l' l'') => IO (HCons (K t (b, a)) l) -> (t -> b -> IO ThreadStatus) -> IO (HCons (K s (d, c)) l') -> (s -> d -> IO ThreadStatus) -> IO (K t (b, c) :*: (K s (d, a) :*: l''))
follows :: HAppend l l' l'' => IO l -> IO l' -> IO l''
cycling :: HLast l last heads => IO l -> IO (HCons last heads)
-- | execute executes a IO hypersequent.
execute :: Lconvertible l => IO l -> IO ()
-- | extend a IO hypersequent with another computation
(-*-) :: (Thread t, IOerSequent l, IOerSequent l') => (t -> a -> IO b) -> (l -> IO l') -> HCons (K t a) l -> IO (HCons (K t b) l')
-- | ThreadStatus shows whether a thread is finished or have to try
-- executing another job.
data ThreadStatus
TryAnotherJob :: ThreadStatus
Finished :: ThreadStatus
instance (Thread t, Lconvertible l) => Lconvertible (HCons (K t ThreadStatus) l)
instance Lconvertible HNil
instance HLast (HCons lh ll) a heads => HLast (HCons b (HCons lh ll)) a (HCons b heads)
instance HLast (HCons a HNil) a HNil
instance (IOerSequent l, HAppend l l' l'') => HAppend (HCons x l) l' (HCons x l'')
instance IOerSequent l => HAppend HNil l l
instance IOerSequent l => IOerSequent (HCons (K t e) l)
instance IOerSequent HNil
instance Thread t => Thread (SucT t)
instance Thread ZeroT