diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-29 17:52:43 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-29 17:52:43 -0400 |
commit | 6b91074b4dda6dff353770e054ae550c7d1c3b4c (patch) | |
tree | e539e242355d306c0e6351053a4fc717902cb93d /Assistant/Types | |
parent | 37d888f9b4a33933b2e894791ed85647c02e6182 (diff) |
split and lift Assistant.Pushes
Diffstat (limited to 'Assistant/Types')
-rw-r--r-- | Assistant/Types/Pushes.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Assistant/Types/Pushes.hs b/Assistant/Types/Pushes.hs new file mode 100644 index 000000000..85362860a --- /dev/null +++ b/Assistant/Types/Pushes.hs @@ -0,0 +1,42 @@ +{- git-annex assistant push tracking + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Assistant.Types.Pushes where + +import Common.Annex +import Utility.TSet + +import Control.Concurrent.STM +import Control.Concurrent.MSampleVar +import Data.Time.Clock +import qualified Data.Map as M + +{- Track the most recent push failure for each remote. -} +type PushMap = M.Map Remote UTCTime +type FailedPushMap = TMVar PushMap + +{- The TSet is recent, successful pushes that other remotes should be + - notified about. + - + - The MSampleVar is written to when the PushNotifier thread should be + - restarted for some reason. + -} +data PushNotifier = PushNotifier + { pushNotifierSuccesses :: TSet UUID + , pushNotifierWaiter :: MSampleVar () + } + +{- The TMVar starts empty, and is left empty when there are no + - failed pushes. This way we can block until there are some failed pushes. + -} +newFailedPushMap :: IO FailedPushMap +newFailedPushMap = atomically newEmptyTMVar + +newPushNotifier :: IO PushNotifier +newPushNotifier = PushNotifier + <$> newTSet + <*> newEmptySV |