on master help sign in
Minor refactor
commit76cd2cc2e0ec579d57348e453b908ab3a25e00a8 authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 25 Jun 2017, 23:34 (9 years ago) parentef68640
1 file changed+5−11
src/Strands/Threads.hs+5−11
src/Strands/Threads.hs+5−11
@@ -162,12 +162,6 @@ waitForOneEvent ctx = do
162162 liftIO $ writeIORef pendingRef p
163163 maybe (return ()) throwM e
164164
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
170−
171165-- XXX this is not a real semaphore as it does not really block on wait,
172166-- instead it returns whether the value is zero or non-zero.
173167--
@@ -180,10 +174,6 @@ waitQSemB sem = atomicModifyIORef sem $ \n ->
180174signalQSemB :: IORef Int -> IO ()
181175signalQSemB sem = atomicModifyIORef sem $ \n -> (n + 1, ())
182176
183−instance Read SomeException where
184− readsPrec _n str = [(SomeException $ ErrorCall s, r)]
185− where [(s , r)] = read str
186−
187177-- Allocation of threads
188178--
189179-- global thread limit
@@ -243,7 +233,7 @@ forkContext context = do
243233 r <- case res of
244234 Left e -> do
245235 dbg $ "beforeExit: " ++ show tid ++ " caught exception"
246− liftIO $ killChildren ctx
236+ liftIO $ readIORef (pendingThreads ctx) >>= mapM_ killThread
247237 return (Just e)
248238 Right _ -> waitForChildren ctx
249239
@@ -288,6 +278,10 @@ resumeContextWith context synch action = do
288278 False -> runContext ctx -- run synchronously
289279 True -> forkContext ctx
290280
281+instance Read SomeException where
282+ readsPrec _n str = [(SomeException $ ErrorCall s, r)]
283+ where [(s , r)] = read str
284+
291285-- | 'StreamData' represents a task in a task stream being generated.
292286data StreamData a =
293287 SMore a -- ^ More tasks to come