Skip to content

Commit 8466bc1

Browse files
authored
work on the sync computations first (#2805)
1 parent 0a78766 commit 8466bc1

File tree

1 file changed

+9
-5
lines changed
  • hls-graph/src/Development/IDE/Graph/Internal

1 file changed

+9
-5
lines changed

hls-graph/src/Development/IDE/Graph/Internal/Database.hs

+9-5
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,14 @@ waitConcurrently_ [] = pure ()
329329
waitConcurrently_ [one] = liftIO $ justWait one
330330
waitConcurrently_ many = do
331331
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
334335
waits <- liftIO $ traverse (waitOrSpawn . fmapWait unmask) many
335-
let asyncs = rights waits
336+
let (syncs, asyncs) = partitionEithers waits
336337
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

0 commit comments

Comments
 (0)