File tree 1 file changed +9
-5
lines changed
hls-graph/src/Development/IDE/Graph/Internal
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -329,10 +329,14 @@ waitConcurrently_ [] = pure ()
329
329
waitConcurrently_ [one] = liftIO $ justWait one
330
330
waitConcurrently_ many = do
331
331
ref <- AIO ask
332
- -- mask to make sure we keep track of all the asyncs
333
- waits <- liftIO $ uninterruptibleMask $ \ unmask -> do
332
+ -- spawn the async computations.
333
+ -- mask to make sure we keep track of all the asyncs.
334
+ (asyncs, syncs) <- liftIO $ uninterruptibleMask $ \ unmask -> do
334
335
waits <- liftIO $ traverse (waitOrSpawn . fmapWait unmask) many
335
- let asyncs = rights waits
336
+ let (syncs, asyncs) = partitionEithers waits
336
337
liftIO $ atomicModifyIORef'_ ref (asyncs ++ )
337
- return waits
338
- liftIO $ traverse_ (either id wait) waits
338
+ return (asyncs, syncs)
339
+ -- work on the sync computations
340
+ liftIO $ sequence_ syncs
341
+ -- wait for the async computations before returning
342
+ liftIO $ traverse_ wait asyncs
You can’t perform that action at this time.
0 commit comments