priority-sync- Cooperative task prioritization.




data Room u Source

A resource pool, parameterized against arbitrary user data.


Eq (Room u) 
Ord (Room u) 
RoomGroup (Room u) 
Occupancy (Room u) 

newRoom :: u -> IO (Room u)Source

Create a new Room with some arbitrary user data.

userData :: Room u -> uSource

Get the user data associated with a Room.

inUse :: Room u -> STM (Set ThreadId)Source

Get all ThreadIds that are currently claiming this Room.

data Claim u Source

A Claim, or attempt to acquire or release a Room.

claimedRoom :: Claim u -> Room uSource

Get the Room target of a Claim.

claimedThread :: Claim u -> ThreadIdSource

Get the thread attempting a Claim.

data ClaimMode Source




claim :: (RoomGroup c, ClaimContext c) => ClaimMode -> c -> IO a -> IO aSource

Temporarily Acquire, and then release, or Release, and then acquire, some Rooms for the duration of a critical section. A simple example where a room might be used to prevent interleaving of stdout:

 room <- newRoom (MaxThreads 1)
 forkIO $ claim Acquire (Default,room) $ putStrLn "Hello World!"
 forkIO $ claim Acquire (Default,room) $ putStrLn "Foo!  Bar!"

approveClaims :: RoomConstraint u => [Claim u] -> STM ()Source

approve some claims according to their constraints.

approve :: Claim u -> STM ()Source

Approve a claim. This actually acquires or releases a Room.

isEmpty :: Room u -> STM BoolSource

True iff a Room is empty.