Skip to content

Commit 396aeab

Browse files
committed
io-sim-por: update timeout's TVar's vector clocks
1 parent 8d5c417 commit 396aeab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ schedule thread@Thread{
425425
tvar <- execNewTVar nextVid
426426
(Just $ "<<timeout-state " ++ show (unTimeoutId nextTmid) ++ ">>")
427427
TimeoutPending
428+
modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
428429
tvar' <- execNewTVar (succ nextVid)
429430
(Just $ "<<timeout " ++ show (unTimeoutId nextTmid) ++ ">>")
430431
False
432+
modifySTRef (tvarVClock tvar') (leastUpperBoundVClock vClock)
431433
let expiry = d `addTime` time
432434
t = Timeout tvar tvar' nextTmid
433435
timers' = PSQ.insert nextTmid expiry (TimerVars tvar tvar') timers
@@ -461,7 +463,7 @@ schedule thread@Thread{
461463
let thread' = thread { threadControl = ThreadControl k ctl }
462464
schedule thread' simstate
463465

464-
CancelTimeout (Timeout tvar _tvar' tmid) k -> do
466+
CancelTimeout (Timeout tvar tvar' tmid) k -> do
465467
let timers' = PSQ.delete tmid timers
466468
written <- execAtomically' (runSTM $ writeTVar tvar TimeoutCancelled)
467469
(wakeup, wokeby) <- threadsUnblockedByWrites written
@@ -474,6 +476,8 @@ schedule thread@Thread{
474476
}
475477
(unblocked,
476478
simstate') = unblockThreads vClock wakeup simstate
479+
modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
480+
modifySTRef (tvarVClock tvar') (leastUpperBoundVClock vClock)
477481
trace <- deschedule Yield thread' simstate' { timers = timers' }
478482
return $ SimTrace time tid tlbl (EventTimerCancelled tmid)
479483
$ traceMany

0 commit comments

Comments
 (0)