refactor
This commit is contained in:
parent
26f0f8b20f
commit
ba433bdc85
1 changed files with 6 additions and 9 deletions
|
@ -118,6 +118,9 @@ changeStageTo mytid tv newstage = liftIO $
|
||||||
where
|
where
|
||||||
replaceidle = atomically $ do
|
replaceidle = atomically $ do
|
||||||
pool <- takeTMVar tv
|
pool <- takeTMVar tv
|
||||||
|
let notchanging = do
|
||||||
|
putTMVar tv pool
|
||||||
|
return Nothing
|
||||||
if memberStage newstage (usedStages pool)
|
if memberStage newstage (usedStages pool)
|
||||||
then case removeThreadIdWorkerPool mytid pool of
|
then case removeThreadIdWorkerPool mytid pool of
|
||||||
Just ((myaid, oldstage), pool')
|
Just ((myaid, oldstage), pool')
|
||||||
|
@ -132,15 +135,9 @@ changeStageTo mytid tv newstage = liftIO $
|
||||||
addWorkerPool (IdleWorker oldstage) $
|
addWorkerPool (IdleWorker oldstage) $
|
||||||
addWorkerPool (ActiveWorker myaid newstage) pool''
|
addWorkerPool (ActiveWorker myaid newstage) pool''
|
||||||
return $ Just $ Right oldstage
|
return $ Just $ Right oldstage
|
||||||
| otherwise -> do
|
| otherwise -> notchanging
|
||||||
putTMVar tv pool
|
_ -> notchanging
|
||||||
return Nothing
|
else notchanging
|
||||||
_ -> do
|
|
||||||
putTMVar tv pool
|
|
||||||
return Nothing
|
|
||||||
else do
|
|
||||||
putTMVar tv pool
|
|
||||||
return Nothing
|
|
||||||
|
|
||||||
waitidle (myaid, oldstage) = atomically $ do
|
waitidle (myaid, oldstage) = atomically $ do
|
||||||
pool <- waitIdleWorkerSlot newstage =<< takeTMVar tv
|
pool <- waitIdleWorkerSlot newstage =<< takeTMVar tv
|
||||||
|
|
Loading…
Reference in a new issue