Skip to content

Commit

Permalink
Fix a race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveBarton committed Nov 11, 2023
1 parent e28463a commit 209f604
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions calculi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ library
async,
-- fmt >= 0.4,
ghc-trace-events,
-- hashable, unordered-containers,
-- inspection-testing >= 0.3,
mod,
-- poly >= 0.5.1, deepseq, finite-typelits, vector-sized,
Expand Down
10 changes: 5 additions & 5 deletions src/Math/Algebra/Commutative/GroebnerBasis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,13 @@ groebnerBasis gbpA@(GBPolyOps { .. }) gbTrace gbi0 newGens = TS.scope $ do
writeTVar ijcsRef $! {- TS.measurePure "1.3.1 skipIJCs" $ -}
Set.difference ijcs skipIJCs
pure ijcs
ijcs' <- {- TS.measureM "1.4 addITCs" $ -} atomically $ do
ijcs1 <- readTVar ijcsRef
let ijcs' = {- TS.measurePure "1.4.1 addITCs" $ -}
(ijcs1, ijcs') <- {- TS.measureM "1.4 addITCs" $ -} atomically $ do
ijcs1 <- readTVar ijcsRef
let ijcs' = {- TS.measurePure "1.4.1 addITCs" $ -}
Set.union ijcs1 addITCs
writeTVar ijcsRef ijcs'
pure ijcs'
when (null ijcs && not (null ijcs')) $ inc1TVar wakeAllThreads
pure (ijcs1, ijcs')
when (null ijcs1 && not (null ijcs')) $ inc1TVar wakeAllThreads
when (gbTrace .&. gbTQueues /= 0) $ do
let n = Set.size ijcs
n' = Set.size ijcs'
Expand Down

0 comments on commit 209f604

Please sign in to comment.