Prev Next

Blocking Transactions

 getR :: Resource -> Int -> STM ()
 getR r i = do { v <- readTVar r
               ; if (v < i) then retry
                 else writeTVar r (v-i) }
 atomic (do { getR r1 3; getR r2 7 })
27