@@ -179,25 +179,15 @@ doFork action exHandler =
179179
180180{-# NOINLINE push #-}
181181push :: MonadAsync m => Context m a -> m ()
182−push context = run (Just context) (dequeueLoop context)
182+push ctx = run (Just ctx) (dequeueLoop ctx)
183183
184184 where
185185
186− run ctx m = (runAsyncT m) ctx stop yield
187−
188− chan = childChannel context
189−
190− stop = do
191− tid <- liftIO myThreadId
192− liftIO $ atomically $ writeTBQueue chan (ChildStop tid Nothing)
193−
194− yield a _ Nothing = do
195− tid <- liftIO myThreadId
196− liftIO $ atomically $ writeTBQueue chan (ChildDone tid a)
197−
198− yield a ctx (Just r) = do
199− liftIO $ atomically $ writeTBQueue chan (ChildYield a)
200− run ctx r
186+ send msg = atomically $ writeTBQueue (childChannel ctx) msg
187+ stop = myThreadId >>= \tid -> send (ChildStop tid Nothing)
188+ yield a _ Nothing = liftIO $ myThreadId >>= \tid -> send (ChildDone tid a)
189+ yield a c (Just r) = liftIO (send (ChildYield a)) >> run c r
190+ run c m = (runAsyncT m) c (liftIO stop) yield
201191
202192-- Thread tracking has a significant performance overhead (~20% on empty
203193-- threads, it will be lower for heavy threads). It is needed for two reasons: