0 | module Evince.Async.Synchronized
2 | import Data.Linear.Ref1
4 | import public Evince.Synchronized
16 | acquire : IORef Bool -> Async e [] ()
17 | acquire ref = assert_total $
do
18 | got <- runIO (caswrite1 ref False True)
19 | if got then pure () else (cede >> acquire ref)
24 | asyncWithLock : IORef Bool -> ({0 a : Type} -> Async e [] a -> Async e [] a)
25 | asyncWithLock ref act = do
28 | ignore $
runIO (caswrite1 ref True False)
32 | {e : Type} -> Synchronized (Async e []) where
35 | pure (MkLock (asyncWithLock ref))