@@ -162,12 +162,6 @@ waitForOneEvent ctx = do
162 liftIO $ writeIORef pendingRef p
162 liftIO $ writeIORef pendingRef p
163 maybe (return ()) throwM e
163 maybe (return ()) throwM e
165−-- | kill all the child threads associated with the continuation context
166−killChildren :: Context -> IO ()
167−killChildren ctx = do
168− ths <- readIORef (pendingThreads ctx)
169− mapM_ killThread ths
171-- XXX this is not a real semaphore as it does not really block on wait,
165-- XXX this is not a real semaphore as it does not really block on wait,
172-- instead it returns whether the value is zero or non-zero.
166-- instead it returns whether the value is zero or non-zero.
@@ -180,10 +174,6 @@ waitQSemB sem = atomicModifyIORef sem $ \n ->
180signalQSemB :: IORef Int -> IO ()
174signalQSemB :: IORef Int -> IO ()
181signalQSemB sem = atomicModifyIORef sem $ \n -> (n + 1, ())
175signalQSemB sem = atomicModifyIORef sem $ \n -> (n + 1, ())
183−instance Read SomeException where
184− readsPrec _n str = [(SomeException $ ErrorCall s, r)]
185− where [(s , r)] = read str
187-- Allocation of threads
177-- Allocation of threads
189-- global thread limit
179-- global thread limit
@@ -243,7 +233,7 @@ forkContext context = do
243 r <- case res of
233 r <- case res of
244 Left e -> do
234 Left e -> do
245 dbg $ "beforeExit: " ++ show tid ++ " caught exception"
235 dbg $ "beforeExit: " ++ show tid ++ " caught exception"
246− liftIO $ killChildren ctx
236+ liftIO $ readIORef (pendingThreads ctx) >>= mapM_ killThread
247 return (Just e)
237 return (Just e)
248 Right _ -> waitForChildren ctx
238 Right _ -> waitForChildren ctx
@@ -288,6 +278,10 @@ resumeContextWith context synch action = do
288 False -> runContext ctx -- run synchronously
278 False -> runContext ctx -- run synchronously
289 True -> forkContext ctx
279 True -> forkContext ctx
281+instance Read SomeException where
282+ readsPrec _n str = [(SomeException $ ErrorCall s, r)]
283+ where [(s , r)] = read str
291-- | 'StreamData' represents a task in a task stream being generated.
285-- | 'StreamData' represents a task in a task stream being generated.
292data StreamData a =
286data StreamData a =
293 SMore a -- ^ More tasks to come
287 SMore a -- ^ More tasks to come