@@ -105,9 +105,9 @@ stop = empty
105instance Monad m => Monad (AsyncT m) where
105instance Monad m => Monad (AsyncT m) where
106 return = pure
106 return = pure
108− -- Inner bind operations in 'm' add their 'f' to fstack. If we migrate to
108+ -- Inner bind-operations in 'm' add their 'f' to fstack. If we migrate the
109− -- a new thread somewhere in the middle we unwind the fstack and run these
109+ -- context to a new thread, somewhere in the middle, we unwind the fstack
110− -- functions manually after migration.
110+ -- and run these functions when we resume the context after migration.
111 m >>= f = AsyncT $ do
111 m >>= f = AsyncT $ do
112 saveContext m f
112 saveContext m f
113 runAsyncT m >>= restoreContext >>= runAsyncT
113 runAsyncT m >>= restoreContext >>= runAsyncT
@@ -183,6 +183,8 @@ runContext t = do
183 pendingRef <- liftIO $ newIORef []
183 pendingRef <- liftIO $ newIORef []
184 credit <- liftIO $ newIORef maxBound
184 credit <- liftIO $ newIORef maxBound
186+ -- XXX this should be moved to Context.hs and then we can make m existential
187+ -- and remove the unsafeCoerces
186 r <- runStateT (runAsyncT t) $ initContext
188 r <- runStateT (runAsyncT t) $ initContext
187 (empty :: AsyncT m a) childChan pendingRef credit
189 (empty :: AsyncT m a) childChan pendingRef credit