From ba433bdc8551f8c2f40cd7519298ea9aba480326 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Jun 2019 20:19:38 -0400 Subject: [PATCH] refactor --- Annex/Concurrent.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Annex/Concurrent.hs b/Annex/Concurrent.hs index 703bee8de9..4626a9294f 100644 --- a/Annex/Concurrent.hs +++ b/Annex/Concurrent.hs @@ -118,6 +118,9 @@ changeStageTo mytid tv newstage = liftIO $ where replaceidle = atomically $ do pool <- takeTMVar tv + let notchanging = do + putTMVar tv pool + return Nothing if memberStage newstage (usedStages pool) then case removeThreadIdWorkerPool mytid pool of Just ((myaid, oldstage), pool') @@ -132,15 +135,9 @@ changeStageTo mytid tv newstage = liftIO $ addWorkerPool (IdleWorker oldstage) $ addWorkerPool (ActiveWorker myaid newstage) pool'' return $ Just $ Right oldstage - | otherwise -> do - putTMVar tv pool - return Nothing - _ -> do - putTMVar tv pool - return Nothing - else do - putTMVar tv pool - return Nothing + | otherwise -> notchanging + _ -> notchanging + else notchanging waitidle (myaid, oldstage) = atomically $ do pool <- waitIdleWorkerSlot newstage =<< takeTMVar tv