it builds again
Currently nothing waits on transfer processes. (Second drive of the day fried. Not concentrating very well.)
This commit is contained in:
parent
8795a392c3
commit
430ad8ce85
3 changed files with 39 additions and 5 deletions
|
@ -84,6 +84,7 @@ import Assistant.Changes
|
||||||
import Assistant.Commits
|
import Assistant.Commits
|
||||||
import Assistant.Pushes
|
import Assistant.Pushes
|
||||||
import Assistant.TransferQueue
|
import Assistant.TransferQueue
|
||||||
|
import Assistant.TransferSlots
|
||||||
import Assistant.Threads.Watcher
|
import Assistant.Threads.Watcher
|
||||||
import Assistant.Threads.Committer
|
import Assistant.Threads.Committer
|
||||||
import Assistant.Threads.Pusher
|
import Assistant.Threads.Pusher
|
||||||
|
@ -122,7 +123,7 @@ startDaemon assistant foreground
|
||||||
, pushThread st dstatus commitchan pushmap
|
, pushThread st dstatus commitchan pushmap
|
||||||
, pushRetryThread st pushmap
|
, pushRetryThread st pushmap
|
||||||
, mergeThread st
|
, mergeThread st
|
||||||
, transferWatcherThread st dstatus transferslots
|
, transferWatcherThread st dstatus
|
||||||
, transfererThread st dstatus transferqueue transferslots
|
, transfererThread st dstatus transferqueue transferslots
|
||||||
, daemonStatusThread st dstatus
|
, daemonStatusThread st dstatus
|
||||||
, sanityCheckerThread st dstatus transferqueue changechan
|
, sanityCheckerThread st dstatus transferqueue changechan
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Common.Annex
|
||||||
import Assistant.ThreadedMonad
|
import Assistant.ThreadedMonad
|
||||||
import Assistant.DaemonStatus
|
import Assistant.DaemonStatus
|
||||||
import Assistant.TransferQueue
|
import Assistant.TransferQueue
|
||||||
|
import Assistant.TransferSlots
|
||||||
import Logs.Transfer
|
import Logs.Transfer
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
|
@ -25,14 +26,16 @@ maxTransfers :: Int
|
||||||
maxTransfers = 1
|
maxTransfers = 1
|
||||||
|
|
||||||
{- Dispatches transfers from the queue. -}
|
{- Dispatches transfers from the queue. -}
|
||||||
transfererThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> IO ()
|
transfererThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> TransferSlots -> IO ()
|
||||||
transfererThread st dstatus transferqueue = runEvery (Seconds 1) $ do
|
transfererThread st dstatus transferqueue slots = runEvery (Seconds 1) $ do
|
||||||
(t, info) <- getNextTransfer transferqueue
|
(t, info) <- getNextTransfer transferqueue
|
||||||
c <- runThreadState st $ shouldTransfer dstatus t
|
c <- runThreadState st $ shouldTransfer dstatus t
|
||||||
|
let run = void $ inTransferSlot slots $
|
||||||
|
runTransfer st dstatus t info
|
||||||
case c of
|
case c of
|
||||||
Yes -> void $ runTransfer st dstatus t info
|
Yes -> run
|
||||||
Skip -> noop
|
Skip -> noop
|
||||||
TooMany -> void $ waitTransfer >> runTransfer st dstatus t info
|
TooMany -> waitTransfer >> run
|
||||||
|
|
||||||
data ShouldTransfer = Yes | Skip | TooMany
|
data ShouldTransfer = Yes | Skip | TooMany
|
||||||
|
|
||||||
|
|
30
Assistant/TransferSlots.hs
Normal file
30
Assistant/TransferSlots.hs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{- git-annex assistant transfer slots
|
||||||
|
-
|
||||||
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Assistant.TransferSlots where
|
||||||
|
|
||||||
|
import Control.Exception
|
||||||
|
import Control.Concurrent
|
||||||
|
|
||||||
|
type TransferSlots = QSemN
|
||||||
|
|
||||||
|
{- Number of concurrent transfers allowed to be run from the assistant.
|
||||||
|
-
|
||||||
|
- Transfers launched by other means, including by remote assistants,
|
||||||
|
- do not currently take up slots.
|
||||||
|
-}
|
||||||
|
numSlots :: Int
|
||||||
|
numSlots = 1
|
||||||
|
|
||||||
|
newTransferSlots :: IO TransferSlots
|
||||||
|
newTransferSlots = newQSemN numSlots
|
||||||
|
|
||||||
|
{- Waits until a transfer slot becomes available, and runs a transfer
|
||||||
|
- action in the slot.
|
||||||
|
-}
|
||||||
|
inTransferSlot :: TransferSlots -> IO a -> IO a
|
||||||
|
inTransferSlot s = bracket_ (waitQSemN s 1) (signalQSemN s 1)
|
Loading…
Add table
Add a link
Reference in a new issue