Skip to content

Commit fc24459

Browse files
committed
io-sim: haddocks & code style
1 parent 3925fad commit fc24459

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,8 @@ execNewTVar !tvarId !mbLabel x = do
12361236
!tvarBlocked <- newSTRef ([], Set.empty)
12371237
!tvarVClock <- newSTRef $! VectorClock Map.empty
12381238
!tvarTrace <- newSTRef $! Nothing
1239-
return TVar {tvarId, tvarLabel,
1240-
tvarCurrent, tvarUndo, tvarBlocked, tvarVClock,
1241-
tvarTrace}
1239+
return TVar {tvarId, tvarLabel, tvarCurrent, tvarUndo, tvarBlocked,
1240+
tvarVClock, tvarTrace}
12421241

12431242

12441243
-- 'execReadTVar' is defined in `Control.Monad.IOSim.Type` and shared with /IOSimPOR/

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ schedule thread@Thread{
561561
timers' = PSQ.insert nextTmid expiry (Timer tvar) timers
562562
thread' = thread { threadControl = ThreadControl (k t) ctl }
563563
trace <- schedule thread' simstate { timers = timers'
564-
, nextVid = succ (succ nextVid)
565-
, nextTmid = succ nextTmid }
564+
, nextVid = succ (succ nextVid)
565+
, nextTmid = succ nextTmid }
566566
return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid (TVarId nextVid) expiry) trace)
567567

568568
CancelTimeout (Timeout tvar tmid) k -> do
@@ -1849,7 +1849,8 @@ normalizeRaces Races{ activeRaces, completeRaces } =
18491849
$ activeRaces
18501850
)
18511851
++ completeRaces
1852-
in Races{ activeRaces = activeRaces', completeRaces = completeRaces' }
1852+
in Races{ activeRaces = activeRaces',
1853+
completeRaces = completeRaces' }
18531854

18541855

18551856
-- When a thread terminates, we remove it from the concurrent thread

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,9 @@ instance Monoid Effect where
6969
-- Effect smart constructors
7070
--
7171

72-
-- readEffect :: SomeTVar s -> Effect
73-
-- readEffect r = mempty{effectReads = Set.singleton $ someTvarId r }
74-
7572
readEffects :: [Labelled (SomeTVar s)] -> Effect
7673
readEffects rs = mempty{effectReads = Set.fromList (map (someTvarId <$>) rs)}
7774

78-
-- writeEffect :: SomeTVar s -> Effect
79-
-- writeEffect r = mempty{effectWrites = Set.singleton $ someTvarId r }
80-
8175
writeEffects :: [Labelled (SomeTVar s)] -> Effect
8276
writeEffects rs = mempty{effectWrites = Set.fromList (map (someTvarId <$>) rs)}
8377

@@ -224,11 +218,18 @@ data StepInfo = StepInfo {
224218
-- Races
225219
--
226220

227-
data Races = Races { -- These steps may still race with future steps
228-
activeRaces :: ![StepInfo],
229-
-- These steps cannot be concurrent with future steps
230-
completeRaces :: ![StepInfo]
231-
}
221+
-- | Information about all discovered races in a simulation categorised as
222+
-- active and complete races.
223+
--
224+
-- See 'normalizeRaces' how we split `StepInfo` into the two categories.
225+
--
226+
data Races = Races {
227+
-- | These steps may still race with future steps.
228+
activeRaces :: ![StepInfo],
229+
230+
-- | These steps cannot be concurrent with future steps.
231+
completeRaces :: ![StepInfo]
232+
}
232233
deriving Show
233234

234235
noRaces :: Races

0 commit comments

Comments
 (0)