Skip to content

Commit 04158c0

Browse files
committed
io-sim-por: converted effectWakeup to a set
1 parent 2bbeeb1 commit 04158c0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

io-sim/src/Control/Monad/IOSimPOR/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ updateRaces thread@Thread { threadId = tid }
17451745
}
17461746
where
17471747
concurrent :: Set ThreadId
1748-
concurrent = foldr Set.delete concurrent0 (effectWakeup newEffect)
1748+
concurrent = concurrent0 Set.\\ effectWakeup newEffect
17491749

17501750
isBlocking :: Bool
17511751
isBlocking = isThreadBlocked thread && onlyReadEffect newEffect
@@ -1758,7 +1758,7 @@ updateRaces thread@Thread { threadId = tid }
17581758
stepInfoRaces } =
17591759
-- if this step depends on the previous step, or is not concurrent,
17601760
-- then any threads that it wakes up become non-concurrent also.
1761-
let !lessConcurrent = foldr Set.delete concurrent (effectWakeup newEffect) in
1761+
let !lessConcurrent = concurrent Set.\\ effectWakeup newEffect in
17621762

17631763
if tid `notElem` concurrent
17641764
then stepInfo { stepInfoConcurrent = lessConcurrent }

io-sim/src/Control/Monad/IOSimPOR/Types.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ data Effect = Effect {
4040
effectWrites :: !(Set TVarId),
4141
effectForks :: !(Set ThreadId),
4242
effectThrows :: ![ThreadId],
43-
effectWakeup :: ![ThreadId]
43+
effectWakeup :: !(Set ThreadId)
4444
}
4545
deriving Eq
4646

@@ -57,10 +57,10 @@ instance Show Effect where
5757

5858
instance Semigroup Effect where
5959
Effect r w s ts wu <> Effect r' w' s' ts' wu' =
60-
Effect (r <> r') (w <> w') (s <> s') (ts ++ ts') (wu++wu')
60+
Effect (r <> r') (w <> w') (s <> s') (ts ++ ts') (wu <> wu')
6161

6262
instance Monoid Effect where
63-
mempty = Effect Set.empty Set.empty Set.empty [] []
63+
mempty = Effect Set.empty Set.empty Set.empty [] Set.empty
6464

6565
--
6666
-- Effect smart constructors
@@ -85,7 +85,7 @@ throwToEffect :: ThreadId -> Effect
8585
throwToEffect tid = mempty{ effectThrows = [tid] }
8686

8787
wakeupEffects :: [ThreadId] -> Effect
88-
wakeupEffects tids = mempty{effectWakeup = tids}
88+
wakeupEffects tids = mempty{effectWakeup = Set.fromList tids}
8989

9090
--
9191
-- Utils

0 commit comments

Comments
 (0)