Skip to content

Commit 1c290b0

Browse files
committed
wait if there is just one key
1 parent fc4bafd commit 1c290b0

File tree

1 file changed

+2
-15
lines changed
  • hls-graph/src/Development/IDE/Graph/Internal

1 file changed

+2
-15
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ builder db@Database{..} stack keys = withRunInIO $ \(RunInIO run) -> do
109109
-- Things that I need to force before my results are ready
110110
toForce <- liftIO $ newTVarIO []
111111
current <- liftIO $ readTVarIO databaseStep
112+
let spawnOrWait = if length keys > 1 then Spawn else Wait
112113
results <- liftIO $ for keys $ \id ->
113114
-- Updating the status of all the dependencies atomically is not necessary.
114115
-- Therefore, run one transaction per dep. to avoid contention
@@ -126,7 +127,7 @@ builder db@Database{..} stack keys = withRunInIO $ \(RunInIO run) -> do
126127
let act = run (refresh db stack id s)
127128
(force, val) = splitIO act
128129
SMap.focus (updateStatus $ Running current force val s) id databaseValues
129-
modifyTVar' toForce (Spawn force:)
130+
modifyTVar' toForce (spawnOrWait force:)
130131
pure val
131132

132133
pure (id, val)
@@ -312,20 +313,6 @@ runAIO (AIO act) = do
312313

313314
-- | Like 'async' but with built-in cancellation.
314315
-- Returns an IO action to wait on the result.
315-
asyncWithCleanUp :: AIO a -> AIO (IO a)
316-
asyncWithCleanUp act = do
317-
st <- AIO ask
318-
io <- unliftAIO act
319-
-- mask to make sure we keep track of the spawned async
320-
liftIO $ uninterruptibleMask $ \restore -> do
321-
a <- async $ restore io
322-
atomicModifyIORef'_ st (void a :)
323-
return $ wait a
324-
325-
unliftAIO :: AIO a -> AIO (IO a)
326-
unliftAIO act = do
327-
st <- AIO ask
328-
return $ runReaderT (unAIO act) st
329316

330317
newtype RunInIO = RunInIO (forall a. AIO a -> IO a)
331318

0 commit comments

Comments
 (0)