@@ -449,11 +449,27 @@ schedule thread@Thread{
449
449
let thread' = thread { threadControl = ThreadControl k ctl }
450
450
schedule thread' simstate
451
451
452
- CancelTimeout (Timeout _tvar _tvar' tmid) k -> do
452
+ CancelTimeout (Timeout tvar _tvar' tmid) k -> do
453
453
let timers' = PSQ. delete tmid timers
454
- thread' = thread { threadControl = ThreadControl k ctl }
455
- trace <- schedule thread' simstate { timers = timers' }
456
- return (SimTrace time tid tlbl (EventTimerCancelled tmid) trace)
454
+ written <- execAtomically' (runSTM $ writeTVar tvar TimeoutCancelled )
455
+ (wakeup, wokeby) <- threadsUnblockedByWrites written
456
+ mapM_ (\ (SomeTVar var) -> unblockAllThreadsFromTVar var) written
457
+ let effect' = effect
458
+ <> writeEffects written
459
+ <> wakeupEffects wakeup
460
+ thread' = thread { threadControl = ThreadControl k ctl
461
+ , threadEffect = effect'
462
+ }
463
+ (unblocked,
464
+ simstate') = unblockThreads vClock wakeup simstate
465
+ trace <- deschedule Yield thread' simstate' { timers = timers' }
466
+ return $ SimTrace time tid tlbl (EventTimerCancelled tmid)
467
+ $ traceMany
468
+ [ (time, tid', tlbl', EventTxWakeup vids)
469
+ | tid' <- unblocked
470
+ , let tlbl' = lookupThreadLabel tid' threads
471
+ , let Just vids = Set. toList <$> Map. lookup tid' wokeby ]
472
+ $ trace
457
473
458
474
-- cancelling a negative timer is a no-op
459
475
CancelTimeout (NegativeTimeout _tmid) k -> do
0 commit comments