Skip to content

Commit

Permalink
io-sim: haddocks & code style
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Oct 6, 2024
1 parent 3925fad commit fc24459
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
5 changes: 2 additions & 3 deletions io-sim/src/Control/Monad/IOSim/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,9 +1236,8 @@ execNewTVar !tvarId !mbLabel x = do
!tvarBlocked <- newSTRef ([], Set.empty)
!tvarVClock <- newSTRef $! VectorClock Map.empty
!tvarTrace <- newSTRef $! Nothing
return TVar {tvarId, tvarLabel,
tvarCurrent, tvarUndo, tvarBlocked, tvarVClock,
tvarTrace}
return TVar {tvarId, tvarLabel, tvarCurrent, tvarUndo, tvarBlocked,
tvarVClock, tvarTrace}


-- 'execReadTVar' is defined in `Control.Monad.IOSim.Type` and shared with /IOSimPOR/
Expand Down
7 changes: 4 additions & 3 deletions io-sim/src/Control/Monad/IOSimPOR/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ schedule thread@Thread{
timers' = PSQ.insert nextTmid expiry (Timer tvar) timers
thread' = thread { threadControl = ThreadControl (k t) ctl }
trace <- schedule thread' simstate { timers = timers'
, nextVid = succ (succ nextVid)
, nextTmid = succ nextTmid }
, nextVid = succ (succ nextVid)
, nextTmid = succ nextTmid }
return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid (TVarId nextVid) expiry) trace)

CancelTimeout (Timeout tvar tmid) k -> do
Expand Down Expand Up @@ -1849,7 +1849,8 @@ normalizeRaces Races{ activeRaces, completeRaces } =
$ activeRaces
)
++ completeRaces
in Races{ activeRaces = activeRaces', completeRaces = completeRaces' }
in Races{ activeRaces = activeRaces',
completeRaces = completeRaces' }


-- When a thread terminates, we remove it from the concurrent thread
Expand Down
23 changes: 12 additions & 11 deletions io-sim/src/Control/Monad/IOSimPOR/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ instance Monoid Effect where
-- Effect smart constructors
--

-- readEffect :: SomeTVar s -> Effect
-- readEffect r = mempty{effectReads = Set.singleton $ someTvarId r }

readEffects :: [Labelled (SomeTVar s)] -> Effect
readEffects rs = mempty{effectReads = Set.fromList (map (someTvarId <$>) rs)}

-- writeEffect :: SomeTVar s -> Effect
-- writeEffect r = mempty{effectWrites = Set.singleton $ someTvarId r }

writeEffects :: [Labelled (SomeTVar s)] -> Effect
writeEffects rs = mempty{effectWrites = Set.fromList (map (someTvarId <$>) rs)}

Expand Down Expand Up @@ -224,11 +218,18 @@ data StepInfo = StepInfo {
-- Races
--

data Races = Races { -- These steps may still race with future steps
activeRaces :: ![StepInfo],
-- These steps cannot be concurrent with future steps
completeRaces :: ![StepInfo]
}
-- | Information about all discovered races in a simulation categorised as
-- active and complete races.
--
-- See 'normalizeRaces' how we split `StepInfo` into the two categories.
--
data Races = Races {
-- | These steps may still race with future steps.
activeRaces :: ![StepInfo],

-- | These steps cannot be concurrent with future steps.
completeRaces :: ![StepInfo]
}
deriving Show

noRaces :: Races
Expand Down

0 comments on commit fc24459

Please sign in to comment.