Skip to content

Commit 8c9b023

Browse files
committed
io-sim-por: refactored advanceControl
1 parent b82857d commit 8c9b023

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,23 +1501,27 @@ controlFollows stepId (ControlFollow (stepId':_) _) = stepId == stepId'
15011501
controlFollows stepId (ControlAwait (smod:_)) = stepId /= scheduleModTarget smod
15021502
controlFollows _ (ControlAwait []) = error "Impossible: controlFollows _ (ControlAwait [])"
15031503

1504-
advanceControl :: (ThreadId, Int) -> ScheduleControl -> ScheduleControl
1505-
advanceControl (tid,step) (ControlFollow ((tid',step'):sids) tgts)
1504+
advanceControl :: StepId -> ScheduleControl -> ScheduleControl
1505+
advanceControl (tid,step) control@(ControlFollow ((tid',step'):sids') tgts)
15061506
| tid /= tid' =
15071507
-- we are switching threads to follow the schedule
1508-
--Debug.trace ("Switching threads from "++show (tid,step)++" to "++show (tid',step')++"\n") $
1509-
ControlFollow ((tid',step'):sids) tgts
1508+
--Debug.trace ("Switching threads from "++show (tid,step)++" to "++show (tid',step')++"\n") $
1509+
control
15101510
| step == step' =
1511-
ControlFollow sids tgts
1511+
ControlFollow sids' tgts
15121512
| otherwise =
1513-
error $ "advanceControl "++show (tid,step)++" cannot follow step "++show step'++"\n"
1513+
error $ concat
1514+
[ "advanceControl ", show (tid,step)
1515+
, " cannot follow step ", show step'
1516+
, "\n"
1517+
]
15141518
advanceControl stepId (ControlFollow [] []) =
15151519
ControlDefault
15161520
advanceControl stepId (ControlFollow [] tgts) =
15171521
ControlAwait tgts
1518-
advanceControl stepId c =
1519-
assert (not $ controlTargets stepId c) $
1520-
c
1522+
advanceControl stepId control =
1523+
assert (not $ controlTargets stepId control) $
1524+
control
15211525

15221526
followControl :: ScheduleControl -> ScheduleControl
15231527
followControl (ControlAwait (ScheduleMod { scheduleModInsertion } : mods)) =

0 commit comments

Comments
 (0)