Skip to content

Commit 3681605

Browse files
committed
io-sim-por: evaluate deschedule & reschedule to WHNF
1 parent 924b326 commit 3681605

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ schedule thread@Thread{
302302

303303
ForkFrame -> do
304304
-- this thread is done
305-
trace <- deschedule Terminated thread simstate
305+
!trace <- deschedule Terminated thread simstate
306306
return $ SimPORTrace time tid tstep tlbl EventThreadFinished
307307
$ SimPORTrace time tid tstep tlbl (EventDeschedule Terminated)
308308
$ trace
@@ -312,7 +312,7 @@ schedule thread@Thread{
312312
let thread' = thread { threadControl = ThreadControl (k x) ctl'
313313
, threadMasking = maskst' }
314314
-- but if we're now unmasked, check for any pending async exceptions
315-
trace <- deschedule Interruptable thread' simstate
315+
!trace <- deschedule Interruptable thread' simstate
316316
return $ SimPORTrace time tid tstep tlbl (EventMask maskst')
317317
$ SimPORTrace time tid tstep tlbl (EventDeschedule Interruptable)
318318
$ trace
@@ -345,7 +345,7 @@ schedule thread@Thread{
345345

346346
| otherwise -> do
347347
-- An unhandled exception in any other thread terminates the thread
348-
trace <- deschedule Terminated thread simstate
348+
!trace <- deschedule Terminated thread simstate
349349
return $ SimPORTrace time tid tstep tlbl (EventThrow e)
350350
$ SimPORTrace time tid tstep tlbl (EventThreadUnhandled e)
351351
$ SimPORTrace time tid tstep tlbl (EventDeschedule Terminated)
@@ -482,7 +482,7 @@ schedule thread@Thread{
482482
simstate') = unblockThreads vClock wakeup simstate
483483
modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
484484
modifySTRef (tvarVClock tvar') (leastUpperBoundVClock vClock)
485-
trace <- deschedule Yield thread' simstate' { timers = timers' }
485+
!trace <- deschedule Yield thread' simstate' { timers = timers' }
486486
return $ SimPORTrace time tid tstep tlbl (EventTimerCancelled tmid)
487487
$ traceMany
488488
-- TODO: step
@@ -524,9 +524,9 @@ schedule thread@Thread{
524524
}
525525
threads' = Map.insert tid' thread'' threads
526526
-- A newly forked thread may have a higher priority, so we deschedule this one.
527-
trace <- deschedule Yield thread'
528-
simstate { runqueue = insertThread thread'' runqueue
529-
, threads = threads' }
527+
!trace <- deschedule Yield thread'
528+
simstate { runqueue = insertThread thread'' runqueue
529+
, threads = threads' }
530530
return $ SimPORTrace time tid tstep tlbl (EventThreadForked tid')
531531
$ SimPORTrace time tid tstep tlbl (EventDeschedule Yield)
532532
$ trace
@@ -553,7 +553,7 @@ schedule thread@Thread{
553553
written' <- traverse (\(SomeTVar tvar) -> labelledTVarId tvar) written
554554
created' <- traverse (\(SomeTVar tvar) -> labelledTVarId tvar) created
555555
-- We deschedule a thread after a transaction... another may have woken up.
556-
trace <- deschedule Yield thread' simstate' { nextVid = nextVid' }
556+
!trace <- deschedule Yield thread' simstate' { nextVid = nextVid' }
557557
return $
558558
SimPORTrace time tid tstep tlbl (EventTxCommitted written' created' (Just effect')) $
559559
traceMany
@@ -591,7 +591,7 @@ schedule thread@Thread{
591591
let effect' = effect <> readEffects read
592592
thread' = thread { threadVClock = vClock `leastUpperBoundVClock` vClockRead,
593593
threadEffect = effect' }
594-
trace <- deschedule Blocked thread' simstate
594+
!trace <- deschedule Blocked thread' simstate
595595
return $ SimPORTrace time tid tstep tlbl (EventTxBlocked vids (Just effect'))
596596
$ SimPORTrace time tid tstep tlbl (EventDeschedule Blocked)
597597
$ trace
@@ -743,7 +743,7 @@ deschedule Interruptable thread@Thread {
743743
(unblocked,
744744
simstate') = unblockThreads vClock [l_labelled tid'] simstate
745745
-- the thread is stepped when we Yield
746-
trace <- deschedule Yield thread' simstate'
746+
!trace <- deschedule Yield thread' simstate'
747747
return $ SimPORTrace time tid tstep tlbl (EventDeschedule Yield)
748748
$ SimPORTrace time tid tstep tlbl (EventThrowToUnmasked tid')
749749
-- TODO: step
@@ -790,7 +790,7 @@ deschedule Terminated thread@Thread { threadId = tid, threadVClock = vClock }
790790
threads' = Map.insert tid thread' threads
791791
-- We must keep terminated threads in the state to preserve their vector clocks,
792792
-- which matters when other threads throwTo them.
793-
trace <- reschedule simstate' { races = threadTerminatesRaces tid $
793+
!trace <- reschedule simstate' { races = threadTerminatesRaces tid $
794794
updateRacesInSimState thread simstate,
795795
control = advanceControl (threadStepId thread) control,
796796
threads = threads' }
@@ -874,8 +874,8 @@ reschedule simstate@SimState{ threads, timers, curTime = time, races } =
874874
simstate') = unblockThreads bottomVClock wakeup simstate
875875
-- all open races will be completed and reported at this time
876876
simstate'' = simstate'{ races = noRaces }
877-
trace <- reschedule simstate'' { curTime = time'
878-
, timers = timers' }
877+
!trace <- reschedule simstate'' { curTime = time'
878+
, timers = timers' }
879879
let traceEntries =
880880
[ (time', ThreadId [-1], (-1), Just "timer", EventTimerExpired tmid)
881881
| tmid <- tmids ]

0 commit comments

Comments
 (0)