summaryrefslogtreecommitdiff
path: root/Assistant/Changes.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-22 13:39:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-22 14:10:25 -0400
commit28e28bc0436cb0a33e570b1a1f678e80a770a21a (patch)
treed9acb7b66a19a64d6108f980c081f2537c9af353 /Assistant/Changes.hs
parent3ee44cf8feb11fc439c02eb0eb8f12d290b01120 (diff)
stub syncer thread and commit channel
Diffstat (limited to 'Assistant/Changes.hs')
-rw-r--r--Assistant/Changes.hs25
1 files changed, 9 insertions, 16 deletions
diff --git a/Assistant/Changes.hs b/Assistant/Changes.hs
index 173ba1922..47eae83ef 100644
--- a/Assistant/Changes.hs
+++ b/Assistant/Changes.hs
@@ -8,14 +8,14 @@ module Assistant.Changes where
import Common.Annex
import qualified Annex.Queue
import Types.KeySource
+import Utility.TSet
-import Control.Concurrent.STM
import Data.Time.Clock
data ChangeType = AddChange | LinkChange | RmChange | RmDirChange
deriving (Show, Eq)
-type ChangeChan = TChan Change
+type ChangeChan = TSet Change
data Change
= Change
@@ -29,11 +29,8 @@ data Change
}
deriving (Show)
-runChangeChan :: STM a -> IO a
-runChangeChan = atomically
-
newChangeChan :: IO ChangeChan
-newChangeChan = atomically newTChan
+newChangeChan = newTSet
{- Handlers call this when they made a change that needs to get committed. -}
madeChange :: FilePath -> ChangeType -> Annex (Maybe Change)
@@ -65,17 +62,13 @@ finishedChange c = c
{- Gets all unhandled changes.
- Blocks until at least one change is made. -}
getChanges :: ChangeChan -> IO [Change]
-getChanges chan = runChangeChan $ do
- c <- readTChan chan
- go [c]
- where
- go l = do
- v <- tryReadTChan chan
- case v of
- Nothing -> return l
- Just c -> go (c:l)
+getChanges = getTSet
{- Puts unhandled changes back into the channel.
- Note: Original order is not preserved. -}
refillChanges :: ChangeChan -> [Change] -> IO ()
-refillChanges chan cs = runChangeChan $ mapM_ (writeTChan chan) cs
+refillChanges = putTSet
+
+{- Records a change in the channel. -}
+recordChange :: ChangeChan -> Change -> IO ()
+recordChange = putTSet1