avoid spawning new transfer thread until a slot becomes available
This commit is contained in:
parent
522f568450
commit
6107328a6b
2 changed files with 4 additions and 3 deletions
|
@ -19,7 +19,7 @@ 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 lot priority. -}
|
||||
- keep their data in sync. The transfers are queued with low priority. -}
|
||||
transferScannerThread :: ThreadState -> ScanRemoteMap -> TransferQueue -> IO ()
|
||||
transferScannerThread st scanremotes transferqueue = do
|
||||
runEvery (Seconds 2) $ do
|
||||
|
|
|
@ -29,9 +29,10 @@ newTransferSlots = newQSemN numSlots
|
|||
{- Waits until a transfer slot becomes available, and runs a transfer
|
||||
- action in the slot, in its own thread. -}
|
||||
inTransferSlot :: TransferSlots -> ThreadState -> Annex a -> IO ThreadId
|
||||
inTransferSlot s st a = forkIO $ bracket_ start done run
|
||||
inTransferSlot s st a = do
|
||||
waitQSemN s 1
|
||||
forkIO $ bracket_ noop done run
|
||||
where
|
||||
start = waitQSemN s 1
|
||||
done = transferComplete s
|
||||
run = unsafeRunThreadState st a
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue