@@ -42,11 +42,10 @@ import Duct.Context
4242------------------------------------------------------------------------------
4343
4444-- | Continue execution of the closure that we were executing when we migrated
45−-- to a new thread. Run the stack of pending functions in fstack. The types
46−-- don't match. We just coerce the types here, we know that they actually match.
45+-- to a new thread.
4746
48−continue :: Monad m => Context -> StateT Context m (Maybe a)
49−continue = runAsyncT . continueContext
47+resume :: Monad m => Context -> StateT Context m (Maybe a)
48+resume = runAsyncT . resumeContext
5049
5150------------------------------------------------------------------------------
5251-- Thread Management (creation, reaping and killing)
@@ -211,7 +210,7 @@ genAsyncEvents parentc rec = forkMaybe parentc loop
211210 -- pass on the io result and then run the continuation
212211 runContWith dat cont = do
213212 let cont' = cont { event = Just $ unsafeCoerce dat }
214− _ <- runStateT (continue cont') cont'
213+ _ <- runStateT (resume cont') cont'
215214 return ()
216215
217216-- | Run an IO action one or more times to generate a stream of tasks. The IO
@@ -226,6 +225,7 @@ genAsyncEvents parentc rec = forkMaybe parentc loop
226225parallel :: (Monad m, MonadIO m, MonadBaseControl IO m)
227226 => IO (StreamData a) -> AsyncT m (StreamData a)
228227parallel ioaction = AsyncT $ do
228+ -- receive the events via a channel instead
229229 cont <- get
230230 case event cont of
231231 -- we have already exceuted the ioaction and now we are continuing in a new
@@ -238,7 +238,7 @@ parallel ioaction = AsyncT $ do
238238 Nothing -> do
239239 lift $ genAsyncEvents cont ioaction
240240 loc <- getLocation
241− when (loc /= RemoteNode) $ setLocation ForkedThread
241+ when (loc /= RemoteNode) $ setLocation WaitingParent
242242 return Nothing
243243
244244-- | An task stream generator that produces an infinite stream of tasks by
@@ -269,7 +269,7 @@ sync :: MonadIO m => AsyncT m a -> AsyncT m a
269269sync x = AsyncT $ do
270270 setLocation RemoteNode
271271 r <- runAsyncT x
272− setLocation Local
272+ setLocation Worker
273273 return r
274274
275275-- | An task stream generator that produces an infinite stream of tasks by
@@ -311,10 +311,10 @@ react setHandler iob = AsyncT $ do
311311 case event cont of
312312 Nothing -> do
313313 lift $ setHandler $ \dat ->do
314− runStateT (continue cont) cont{event= Just $ unsafeCoerce dat}
314+ runStateT (resume cont) cont{event= Just $ unsafeCoerce dat}
315315 liftIO iob
316316 loc <- getLocation
317− when (loc /= RemoteNode) $ setLocation ForkedThread
317+ when (loc /= RemoteNode) $ setLocation WaitingParent
318318 return Nothing
319319
320320 j@(Just _) -> do