@@ -86,8 +86,8 @@ data ChildEvent a =
8686------------------------------------------------------------------------------
8787
8888data Context m a =
89− Context { childChannel :: TBQueue (ChildEvent a)
90− , pendingWork :: TBQueue (AsyncT m a)
89+ Context { outputQueue :: TBQueue (ChildEvent a)
90+ , workQueue :: TBQueue (AsyncT m a)
9191 , runningThreads :: IORef (Set ThreadId)
9292 , doneThreads :: IORef (Set ThreadId)
9393 }
@@ -185,9 +185,9 @@ push ctx = run (Just ctx) (dequeueLoop ctx)
185185
186186 where
187187
188− send msg = atomically $ writeTBQueue (childChannel ctx) msg
188+ send msg = atomically $ writeTBQueue (outputQueue ctx) msg
189189 stop = do
190− workQEmpty <- liftIO $ atomically $ isEmptyTBQueue (pendingWork ctx)
190+ workQEmpty <- liftIO $ atomically $ isEmptyTBQueue (workQueue ctx)
191191 if (not workQEmpty) then push ctx
192192 else liftIO $ myThreadId >>= \tid -> send (ChildStop tid Nothing)
193193 yield a _ Nothing = liftIO $ myThreadId >>= \tid -> send (ChildDone tid a)
@@ -250,16 +250,16 @@ pullWorker ctx = AsyncT $ \pctx stp yld -> do
250250 done <- f ctx tid
251251 if done then finish else cont
252252
253− res <- liftIO $ atomically $ tryReadTBQueue (childChannel ctx)
253+ res <- liftIO $ atomically $ tryReadTBQueue (outputQueue ctx)
254254 case res of
255255 Nothing -> do
256256 liftIO $ threadDelay 4
257− let workQ = pendingWork ctx
258− outQ = childChannel ctx
257+ let workQ = workQueue ctx
258+ outQ = outputQueue ctx
259259 workQEmpty <- liftIO $ atomically $ isEmptyTBQueue workQ
260260 outQEmpty <- liftIO $ atomically $ isEmptyTBQueue outQ
261261 when (not workQEmpty && outQEmpty) $ pushWorker ctx
262− void $ liftIO $ atomically $ peekTBQueue (childChannel ctx)
262+ void $ liftIO $ atomically $ peekTBQueue (outputQueue ctx)
263263 continue
264264 Just ev ->
265265 case ev of
@@ -289,8 +289,7 @@ handleChildException pchan e = do
289289{-# INLINE pushWorker #-}
290290pushWorker :: MonadAsync m => Context m a -> m ()
291291pushWorker ctx = do
292− let chan = childChannel ctx
293− tid <- doFork (push ctx) (handleChildException chan)
292+ tid <- doFork (push ctx) (handleChildException (outputQueue ctx))
294293 liftIO $ modifyIORef (runningThreads ctx) $ (\s -> S.insert tid s)
295294
296295-- | Split the original computation in a pull-push pair. The original
@@ -305,14 +304,14 @@ pullFork m1 m2 = AsyncT $ \_ stp yld -> do
305304 where
306305
307306 newContext = do
308− channel <- atomically $ newTBQueue 32
309− work <- atomically $ newTBQueue 32
307+ outQ <- atomically $ newTBQueue 32
308+ workQ <- atomically $ newTBQueue 32
310309 running <- newIORef S.empty
311310 done <- newIORef S.empty
312− return $ Context { childChannel = channel
311+ return $ Context { outputQueue = outQ
313312 , runningThreads = running
314313 , doneThreads = done
315− , pendingWork = work
314+ , workQueue = workQ
316315 }
317316
318317-- Concurrency rate control. Our objective is to create more threads on
@@ -349,9 +348,9 @@ pullFork m1 m2 = AsyncT $ \_ stp yld -> do
349348{-# INLINE forkWorker #-}
350349forkWorker :: MonadAsync m => Context m a -> m ()
351350forkWorker ctx = do
352− let chan = childChannel ctx
353− tid <- doFork (push ctx) (handleChildException chan)
354− liftIO $ atomically $ writeTBQueue chan (ChildCreate tid)
351+ let q = outputQueue ctx
352+ tid <- doFork (push ctx) (handleChildException q)
353+ liftIO $ atomically $ writeTBQueue q (ChildCreate tid)
355354
356355{-# INLINE queueWork #-}
357356queueWork :: MonadAsync m => Context m a -> AsyncT m a -> m ()
@@ -363,14 +362,14 @@ queueWork ctx m = do
363362 -- TBD If we run out of threads we can also evaluate the action completely
364363 -- right here, disallowing any further child workers and turning the
365364 -- parallel composition into interleaved serial composition.
366− workQFull <- liftIO $ atomically $ isFullTBQueue (pendingWork ctx)
365+ workQFull <- liftIO $ atomically $ isFullTBQueue (workQueue ctx)
367366 when (workQFull) $ forkWorker ctx
368− liftIO $ atomically $ writeTBQueue (pendingWork ctx) m
367+ liftIO $ atomically $ writeTBQueue (workQueue ctx) m
369368
370369{-# INLINE dequeueLoop #-}
371370dequeueLoop :: MonadAsync m => Context m a -> AsyncT m a
372371dequeueLoop ctx = AsyncT $ \_ stp yld -> do
373− work <- liftIO $ atomically $ tryReadTBQueue (pendingWork ctx)
372+ work <- liftIO $ atomically $ tryReadTBQueue (workQueue ctx)
374373 case work of
375374 Nothing -> stp
376375 Just m -> do