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