diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-29 19:20:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-29 19:20:54 -0400 |
commit | c65199b29e85cb145d460b9e48fe2fc4a10aeb09 (patch) | |
tree | d46f57dc2e021efd8080bc02c9231c603e00963e | |
parent | cb504374b53a940ea12feeb5ba91dd78466be455 (diff) |
split BranchChange and lifted
-rw-r--r-- | Assistant/BranchChange.hs | 17 | ||||
-rw-r--r-- | Assistant/Monad.hs | 2 | ||||
-rw-r--r-- | Assistant/Threads/ConfigMonitor.hs | 2 | ||||
-rw-r--r-- | Assistant/Threads/Merger.hs | 2 | ||||
-rw-r--r-- | Assistant/Types/BranchChange.hs | 19 |
5 files changed, 29 insertions, 13 deletions
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 <joey@kitenet.net> + - + - 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 |