Skip to content

Commit d9a1118

Browse files
committed
fix transaction
1 parent f6451d6 commit d9a1118

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ghcide/src/Development/IDE/Core/Debouncer.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Control.Concurrent.Async
1212
import Control.Concurrent.STM
1313
import Control.Concurrent.STM.Stats (atomicallyNamed)
1414
import Control.Exception
15-
import Control.Monad (join)
15+
import Control.Monad (join, void)
1616
import Data.Hashable
1717
import GHC.Conc (unsafeIOToSTM)
1818
import qualified StmContainers.Map as STM
@@ -40,15 +40,15 @@ asyncRegisterEvent d delay k fire = join $ atomically $ do
4040
prev <- STM.lookup k d
4141
case prev of
4242
Just v -> writeTVar v (delay, fire) >> return (pure ())
43-
Nothing -> return $ do
44-
var <- newTVarIO (delay, fire)
45-
_ <- async $ do
43+
Nothing -> do
44+
var <- newTVar (delay, fire)
45+
STM.insert var k d
46+
return $ void $ async $ do
4647
join $ atomicallyNamed "debouncer - sleep" $ do
4748
(s,act) <- readTVar var
4849
unsafeIOToSTM $ sleep s
4950
STM.delete k d
5051
return act
51-
atomicallyNamed "debouncer2" $ STM.insert var k d
5252

5353
-- | Debouncer used in the DAML CLI compiler that emits events immediately.
5454
noopDebouncer :: Debouncer k

0 commit comments

Comments
 (0)