@@ -129,16 +129,16 @@ forkIt current proc = do
129 -- update the new thread before reclaiming zombies so that if it exited
129 -- update the new thread before reclaiming zombies so that if it exited
130 -- already reclaim finds it in the list and does not panic.
130 -- already reclaim finds it in the list and does not panic.
131 liftIO $ modifyIORef (pendingThreads cur) $ (\ts -> tid:ts)
131 liftIO $ modifyIORef (pendingThreads cur) $ (\ts -> tid:ts)
132− tryReclaimZombies (zombieChannel cur) (pendingThreads cur)
132+ tryReclaimZombies (childChannel cur) (pendingThreads cur)
134 newChildCont cur = do
134 newChildCont cur = do
135 pendingRef <- liftIO $ newIORef []
135 pendingRef <- liftIO $ newIORef []
136 chan <- liftIO $ atomically newTChan
136 chan <- liftIO $ atomically newTChan
137 -- shares the threadCredit of the parent by default
137 -- shares the threadCredit of the parent by default
138 return $ cur
138 return $ cur
139− { parent = Just cur
139+ { parentChannel = Just (childChannel cur)
140 , pendingThreads = pendingRef
140 , pendingThreads = pendingRef
141− , zombieChannel = chan
141+ , childChannel = chan
144 beforeExit cur res = do
144 beforeExit cur res = do
@@ -148,13 +148,13 @@ forkIt current proc = do
148 Right _ -> -- collect the results?
148 Right _ -> -- collect the results?
149 return ()
149 return ()
151− waitForChildren (zombieChannel cur) (pendingThreads cur)
151+ waitForChildren (childChannel cur) (pendingThreads cur)
152 signalQSemB (threadCredit cur)
152 signalQSemB (threadCredit cur)
153 -- We are guaranteed to have a parent because we have been explicitly
153 -- We are guaranteed to have a parent because we have been explicitly
154 -- forked by some parent.
154 -- forked by some parent.
155− let p = fromJust (parent cur)
155+ let p = fromJust (parentChannel cur)
156 tid <- myThreadId
156 tid <- myThreadId
157− liftIO $ atomically $ writeTChan (zombieChannel p) tid
157+ liftIO $ atomically $ writeTChan p tid
159forkMaybe :: (MonadBaseControl IO m, MonadIO m) => EventF -> (EventF -> m ()) -> m ()
159forkMaybe :: (MonadBaseControl IO m, MonadIO m) => EventF -> (EventF -> m ()) -> m ()
160forkMaybe current toRun = do
160forkMaybe current toRun = do
@@ -169,7 +169,7 @@ forkMaybe current toRun = do
169 -- special handling for those cases. Add those to
169 -- special handling for those cases. Add those to
170 -- unreclaimable list? And always execute them in an
170 -- unreclaimable list? And always execute them in an
171 -- async thread, cannot use sync for those.
171 -- async thread, cannot use sync for those.
172− waitForOneChild (zombieChannel current)
172+ waitForOneChild (childChannel current)
173 (pendingThreads current)
173 (pendingThreads current)
174 forkMaybe current toRun
174 forkMaybe current toRun
175 True -> forkIt current toRun
175 True -> forkIt current toRun