summaryrefslogtreecommitdiff
path: root/Assistant/Threads/TransferScanner.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-25 13:12:34 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-25 13:12:34 -0400
commita9dbfdf28d6c97c636e58be85f68d2a3f6efef77 (patch)
tree667c010c9a933535a37d824b424fcae0c2bc35d4 /Assistant/Threads/TransferScanner.hs
parent6107328a6b981ec8130e4154be1ebe7bc11979df (diff)
better transfer queue management
Allow transfers to be added with blocking until the queue is sufficiently small. Better control over which end of the queue to add a transfer to.
Diffstat (limited to 'Assistant/Threads/TransferScanner.hs')
-rw-r--r--Assistant/Threads/TransferScanner.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs
index 485506e7d..3c2e8dfab 100644
--- a/Assistant/Threads/TransferScanner.hs
+++ b/Assistant/Threads/TransferScanner.hs
@@ -18,16 +18,23 @@ import Utility.ThreadScheduler
thisThread :: ThreadName
thisThread = "TransferScanner"
-{- This thread scans remotes, to find transfers that need to be made to
- - keep their data in sync. The transfers are queued with low priority. -}
+{- This thread waits until a remote needs to be scanned, to find transfers
+ - that need to be made, to keep data in sync.
+ -
+ - Remotes are scanned in the background; the scan is blocked when the
+ - transfer queue gets too large.
+ -}
transferScannerThread :: ThreadState -> ScanRemoteMap -> TransferQueue -> IO ()
transferScannerThread st scanremotes transferqueue = do
runEvery (Seconds 2) $ do
r <- getScanRemote scanremotes
needtransfer <- scan st r
forM_ needtransfer $ \(f, t) ->
- queueLaterTransfer transferqueue f t
+ queueTransferAt smallsize Later transferqueue f t
+ where
+ smallsize = 10
+{- -}
scan :: ThreadState -> Remote -> IO [(AssociatedFile, Transfer)]
scan st r = do
debug thisThread ["scanning", show r]