From c65199b29e85cb145d460b9e48fe2fc4a10aeb09 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Oct 2012 19:20:54 -0400 Subject: split BranchChange and lifted --- Assistant/BranchChange.hs | 17 +++++++---------- Assistant/Monad.hs | 2 +- Assistant/Threads/ConfigMonitor.hs | 2 +- Assistant/Threads/Merger.hs | 2 +- Assistant/Types/BranchChange.hs | 19 +++++++++++++++++++ 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 Assistant/Types/BranchChange.hs diff --git a/Assistant/BranchChange.hs b/Assistant/BranchChange.hs index cf7080f90..c9354544a 100644 --- a/Assistant/BranchChange.hs +++ b/Assistant/BranchChange.hs @@ -7,16 +7,13 @@ module Assistant.BranchChange where -import Control.Concurrent.MSampleVar -import Common.Annex - -newtype BranchChangeHandle = BranchChangeHandle (MSampleVar ()) +import Assistant.Common +import Assistant.Types.BranchChange -newBranchChangeHandle :: IO BranchChangeHandle -newBranchChangeHandle = BranchChangeHandle <$> newEmptySV +import Control.Concurrent.MSampleVar -branchChanged :: BranchChangeHandle -> IO () -branchChanged (BranchChangeHandle h) = writeSV h () +branchChanged :: Assistant () +branchChanged = flip writeSV () <<~ (fromBranchChangeHandle . branchChangeHandle) -waitBranchChange :: BranchChangeHandle -> IO () -waitBranchChange (BranchChangeHandle h) = readSV h +waitBranchChange :: Assistant () +waitBranchChange = readSV <<~ (fromBranchChangeHandle . branchChangeHandle) diff --git a/Assistant/Monad.hs b/Assistant/Monad.hs index 47a464d9e..0ddf4ad90 100644 --- a/Assistant/Monad.hs +++ b/Assistant/Monad.hs @@ -32,9 +32,9 @@ import Assistant.Types.ScanRemotes import Assistant.TransferQueue import Assistant.TransferSlots import Assistant.Types.Pushes +import Assistant.Types.BranchChange import Assistant.Commits import Assistant.Changes -import Assistant.BranchChange newtype Assistant a = Assistant { mkAssistant :: ReaderT AssistantData IO a } deriving ( diff --git a/Assistant/Threads/ConfigMonitor.hs b/Assistant/Threads/ConfigMonitor.hs index fe98b10e8..aa4718cf3 100644 --- a/Assistant/Threads/ConfigMonitor.hs +++ b/Assistant/Threads/ConfigMonitor.hs @@ -39,7 +39,7 @@ configMonitorThread = NamedThread "ConfigMonitor" $ loop =<< getConfigs where loop old = do liftIO $ threadDelaySeconds (Seconds 60) - waitBranchChange <<~ branchChangeHandle + waitBranchChange new <- getConfigs when (old /= new) $ do let changedconfigs = new `S.difference` old diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs index a766c5977..46511701c 100644 --- a/Assistant/Threads/Merger.hs +++ b/Assistant/Threads/Merger.hs @@ -66,7 +66,7 @@ onAdd :: Handler onAdd file | ".lock" `isSuffixOf` file = noop | isAnnexBranch file = do - branchChanged <<~ branchChangeHandle + branchChanged transferqueue <- getAssistant transferQueue dstatus <- getAssistant daemonStatusHandle liftAnnex $ diff --git a/Assistant/Types/BranchChange.hs b/Assistant/Types/BranchChange.hs new file mode 100644 index 000000000..399abee54 --- /dev/null +++ b/Assistant/Types/BranchChange.hs @@ -0,0 +1,19 @@ +{- git-annex assistant git-annex branch change tracking + - + - Copyright 2012 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Assistant.Types.BranchChange where + +import Control.Concurrent.MSampleVar +import Common.Annex + +newtype BranchChangeHandle = BranchChangeHandle (MSampleVar ()) + +newBranchChangeHandle :: IO BranchChangeHandle +newBranchChangeHandle = BranchChangeHandle <$> newEmptySV + +fromBranchChangeHandle :: BranchChangeHandle -> MSampleVar () +fromBranchChangeHandle (BranchChangeHandle v) = v -- cgit v1.2.3