diff options
Diffstat (limited to 'Assistant/ThreadedMonad.hs')
-rw-r--r-- | Assistant/ThreadedMonad.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Assistant/ThreadedMonad.hs b/Assistant/ThreadedMonad.hs index 7b915e12c..4e871ab67 100644 --- a/Assistant/ThreadedMonad.hs +++ b/Assistant/ThreadedMonad.hs @@ -36,3 +36,15 @@ withThreadState a = do - time. -} runThreadState :: ThreadState -> Annex a -> IO a runThreadState mvar a = modifyMVar mvar $ \state -> swap <$> Annex.run state a + +{- Runs an Annex action, using a copy of the state from the MVar. + - + - The state modified by the action is thrown away, so it's up to the + - action to perform any necessary shutdown tasks in order for state to not + - be lost. And it's up to the caller to resynchronise with any changes + - the action makes to eg, the git-annex branch. + -} +unsafeRunThreadState :: ThreadState -> Annex a -> IO a +unsafeRunThreadState mvar a = do + state <- readMVar mvar + Annex.eval state a |