Composable blocking transactions, based on the blog post: http://blog.downstairspeople.org/2010/06/06/composable-blocking-transactions/
- data BVar a
- newBVar :: a -> IO (BVar a)
- peekBVar :: BVar a -> IO a
- pokeBVar :: BVar a -> a -> IO ()
- modifyBVar :: BVar a -> (a -> (a, b)) -> IO b
- runBTM :: (forall e. BTM e (Value e a)) -> IO a
- data BTM e a
- data Value e a
- when :: Value e Bool -> BTM e (Value e ()) -> BTM e (Value e ())
- unless :: Value e Bool -> BTM e (Value e ()) -> BTM e (Value e ())
- readBVar :: BVar a -> BTM e (Value e a)
- writeBVar :: BVar a -> Value e a -> BTM e (Value e ())
- retry :: BTM e (Value e ())
- runBTA :: BTA a b -> a -> IO b
- data BTA a b
- fetchBVar :: BVar a -> BTA () a
- storeBVar :: BVar a -> BTA a ()
- retryWhen :: BTA Bool ()
- retryUnless :: BTA Bool ()
Transactional Variables
modifyBVar :: BVar a -> (a -> (a, b)) -> IO bSource
Perform a transaction using only a single variable.
Blocking Transaction Monad
The blocking transaction monad.
An opaque value. It can be modified and combined with other opaque values, but not observed.
The type variable e
binds the value to the monadic context in which it
occurs, (this is identical to the runST
existential type trick).
when :: Value e Bool -> BTM e (Value e ()) -> BTM e (Value e ())Source
Flow control. Skip the critical section if the predicate is false.
unless :: Value e Bool -> BTM e (Value e ()) -> BTM e (Value e ())Source
Flow control. Skip the critical section if the predicate is true.
retry :: BTM e (Value e ())Source
Electively retry. This will restore all variables to their state before the transaction began, and listen for a change to any variable in the working set before trying the transaction again.
Blocking Transaction Arrow
The blocking transaction arrow. The semantics are identical to the equivalent operations on the monadic interface.
Arrow BTA | |
ArrowChoice BTA | |
Category BTA | |
Functor (BTA a) | |
Applicative (BTA a) |