Skip to content

Commit

Permalink
JobPool: renamed collect to waitForJob
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Oct 28, 2022
1 parent fabdf69 commit d384295
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions network-mux/src/Control/Concurrent/JobPool.hs
Expand Up @@ -13,7 +13,7 @@ module Control.Concurrent.JobPool
, forkJob
, readSize
, readGroupSize
, collect
, waitForJob
, cancelGroup
) where

Expand Down Expand Up @@ -99,11 +99,8 @@ readGroupSize JobPool{jobsVar} group =
. Map.filterWithKey (\(group', _) _ -> group' == group)
<$> readTVar jobsVar

collect :: MonadSTM m => JobPool group m a -> STM m a
collect JobPool{completionQueue} = readTQueue completionQueue
-- GR-FIXME[C2]: better name?
-- - 'collect' gives the impression getting many and NOT blocking
-- - how about 'getCompletedJob'?
waitForJob :: MonadSTM m => JobPool group m a -> STM m a
waitForJob JobPool{completionQueue} = readTQueue completionQueue

cancelGroup :: ( MonadAsync m
, Eq group
Expand Down
2 changes: 1 addition & 1 deletion network-mux/src/Network/Mux.hs
Expand Up @@ -362,7 +362,7 @@ monitor tracer timeout jobpool egressQueue cmdQueue muxStatus =
go !monitorCtx@MonitorCtx { mcOnDemandProtocols } = do
result <- atomically $ runFirstToFinish $
-- wait for a mini-protocol thread to terminate
(FirstToFinish $ EventJobResult <$> JobPool.collect jobpool)
(FirstToFinish $ EventJobResult <$> JobPool.waitForJob jobpool)

-- wait for a new control command
<> (FirstToFinish $ EventControlCmd <$> readTQueue cmdQueue)
Expand Down
Expand Up @@ -82,7 +82,7 @@ jobs jobPool st =
-- This case is simple because the job pool returns a 'Completion' which is
-- just a function from the current state to a new 'Decision'.
Guarded Nothing $ do
Completion completion <- JobPool.collect jobPool
Completion completion <- JobPool.waitForJob jobPool
return (completion st)


Expand Down

0 comments on commit d384295

Please sign in to comment.