split BranchChange and lifted

This commit is contained in:
Joey Hess 2012-10-29 19:20:54 -04:00
parent 0c584bf70d
commit 39a3adf434
5 changed files with 29 additions and 13 deletions

View file

@ -7,16 +7,13 @@
module Assistant.BranchChange where
import Assistant.Common
import Assistant.Types.BranchChange
import Control.Concurrent.MSampleVar
import Common.Annex
newtype BranchChangeHandle = BranchChangeHandle (MSampleVar ())
branchChanged :: Assistant ()
branchChanged = flip writeSV () <<~ (fromBranchChangeHandle . branchChangeHandle)
newBranchChangeHandle :: IO BranchChangeHandle
newBranchChangeHandle = BranchChangeHandle <$> newEmptySV
branchChanged :: BranchChangeHandle -> IO ()
branchChanged (BranchChangeHandle h) = writeSV h ()
waitBranchChange :: BranchChangeHandle -> IO ()
waitBranchChange (BranchChangeHandle h) = readSV h
waitBranchChange :: Assistant ()
waitBranchChange = readSV <<~ (fromBranchChangeHandle . branchChangeHandle)

View file

@ -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 (

View file

@ -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

View file

@ -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 $

View file

@ -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