@@ -195,7 +195,7 @@ data SimState s a = SimState {
195195 -- | timeout locks in order to synchronize the timeout handler and the
196196 -- main thread
197197 clocks :: ! (Map ClockId UTCTime ),
198- nextVid :: ! TVarId , -- ^ next unused 'TVarId'
198+ nextVid :: ! VarId , -- ^ next unused 'TVarId'
199199 nextTmid :: ! TimeoutId , -- ^ next unused 'TimeoutId'
200200 -- | previous steps (which we may race with).
201201 -- Note this is *lazy*, so that we don't compute races we will not reverse.
@@ -217,7 +217,7 @@ initialState =
217217 curTime = Time 0 ,
218218 timers = PSQ. empty,
219219 clocks = Map. singleton (ClockId [] ) epoch1970,
220- nextVid = TVarId 0 ,
220+ nextVid = 0 ,
221221 nextTmid = TimeoutId 0 ,
222222 races = noRaces,
223223 control = ControlDefault ,
@@ -480,7 +480,7 @@ schedule thread@Thread{
480480 error " schedule: StartTimeout: Impossible happened"
481481
482482 StartTimeout d action' k -> do
483- lock <- TMVar <$> execNewTVar nextVid (Just $! " lock-" ++ show nextTmid) Nothing
483+ lock <- TMVar <$> execNewTVar ( TMVarId nextVid) (Just $! " lock-" ++ show nextTmid) Nothing
484484 let expiry = d `addTime` time
485485 timers' = PSQ. insert nextTmid expiry (TimerTimeout tid nextTmid lock) timers
486486 thread' = thread { threadControl =
@@ -496,19 +496,19 @@ schedule thread@Thread{
496496 schedule thread' simstate { timers = PSQ. delete tmid timers }
497497
498498 RegisterDelay d k | d < 0 -> do
499- tvar <- execNewTVar nextVid
499+ tvar <- execNewTVar ( TVarId nextVid)
500500 (Just $! " <<timeout " ++ show (unTimeoutId nextTmid) ++ " >>" )
501501 True
502502 modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
503503 let ! expiry = d `addTime` time
504504 ! thread' = thread { threadControl = ThreadControl (k tvar) ctl }
505505 trace <- schedule thread' simstate { nextVid = succ nextVid }
506- return (SimPORTrace time tid tstep tlbl (EventRegisterDelayCreated nextTmid nextVid expiry) $
506+ return (SimPORTrace time tid tstep tlbl (EventRegisterDelayCreated nextTmid ( TVarId nextVid) expiry) $
507507 SimPORTrace time tid tstep tlbl (EventRegisterDelayFired nextTmid) $
508508 trace)
509509
510510 RegisterDelay d k -> do
511- tvar <- execNewTVar nextVid
511+ tvar <- execNewTVar ( TVarId nextVid)
512512 (Just $! " <<timeout " ++ show (unTimeoutId nextTmid) ++ " >>" )
513513 False
514514 modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
@@ -519,7 +519,7 @@ schedule thread@Thread{
519519 , nextVid = succ nextVid
520520 , nextTmid = succ nextTmid }
521521 return (SimPORTrace time tid tstep tlbl
522- (EventRegisterDelayCreated nextTmid nextVid expiry) trace)
522+ (EventRegisterDelayCreated nextTmid ( TVarId nextVid) expiry) trace)
523523
524524 ThreadDelay d k | d < 0 -> do
525525 let expiry = d `addTime` time
@@ -547,12 +547,12 @@ schedule thread@Thread{
547547 expiry = d `addTime` time
548548 thread' = thread { threadControl = ThreadControl (k t) ctl }
549549 trace <- schedule thread' simstate { nextTmid = succ nextTmid }
550- return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid nextVid expiry) $
550+ return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid ( TVarId nextVid) expiry) $
551551 SimPORTrace time tid tstep tlbl (EventTimerCancelled nextTmid) $
552552 trace)
553553
554554 NewTimeout d k -> do
555- tvar <- execNewTVar nextVid
555+ tvar <- execNewTVar ( TVarId nextVid)
556556 (Just $! " <<timeout-state " ++ show (unTimeoutId nextTmid) ++ " >>" )
557557 TimeoutPending
558558 modifySTRef (tvarVClock tvar) (leastUpperBoundVClock vClock)
@@ -563,7 +563,7 @@ schedule thread@Thread{
563563 trace <- schedule thread' simstate { timers = timers'
564564 , nextVid = succ (succ nextVid)
565565 , nextTmid = succ nextTmid }
566- return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid nextVid expiry) trace)
566+ return (SimPORTrace time tid tstep tlbl (EventTimerCreated nextTmid ( TVarId nextVid) expiry) trace)
567567
568568 CancelTimeout (Timeout tvar tmid) k -> do
569569 let timers' = PSQ. delete tmid timers
@@ -1358,7 +1358,7 @@ execAtomically :: forall s a c.
13581358 Time
13591359 -> IOSimThreadId
13601360 -> Maybe ThreadLabel
1361- -> TVarId
1361+ -> VarId
13621362 -> StmA s a
13631363 -> (StmTxResult s a -> ST s (SimTrace c ))
13641364 -> ST s (SimTrace c )
@@ -1371,7 +1371,7 @@ execAtomically !time !tid !tlbl !nextVid0 !action0 !k0 =
13711371 -> Map TVarId (SomeTVar s ) -- set of vars written
13721372 -> [SomeTVar s ] -- vars written in order (no dups)
13731373 -> [SomeTVar s ] -- vars created in order
1374- -> TVarId -- var fresh name supply
1374+ -> VarId -- var fresh name supply
13751375 -> StmA s b
13761376 -> ST s (SimTrace c )
13771377 go ! ctl ! read ! written ! writtenSeq ! createdSeq ! nextVid ! action =
@@ -1470,8 +1470,8 @@ execAtomically !time !tid !tlbl !nextVid0 !action0 !k0 =
14701470 let ctl' = BranchFrame (OrElseStmA b) k written writtenSeq createdSeq ctl
14711471 go ctl' read Map. empty [] [] nextVid a
14721472
1473- NewTVar ! mbLabel x k -> do
1474- ! v <- execNewTVar nextVid mbLabel x
1473+ NewTVar mkId ! mbLabel x k -> do
1474+ ! v <- execNewTVar (mkId nextVid) mbLabel x
14751475 -- record a write to the TVar so we know to update its VClock
14761476 let written' = Map. insert (tvarId v) (SomeTVar v) written
14771477 -- save the value: it will be committed or reverted
@@ -1560,14 +1560,14 @@ execAtomically' = go Map.empty
15601560
15611561
15621562execNewTVar :: TVarId -> Maybe String -> a -> ST s (TVar s a )
1563- execNewTVar nextVid ! mbLabel x = do
1563+ execNewTVar ! tvarId ! mbLabel x = do
15641564 tvarLabel <- newSTRef mbLabel
15651565 tvarCurrent <- newSTRef x
15661566 tvarUndo <- newSTRef []
15671567 tvarBlocked <- newSTRef ([] , Set. empty)
15681568 tvarVClock <- newSTRef bottomVClock
15691569 tvarTrace <- newSTRef Nothing
1570- return TVar {tvarId = nextVid , tvarLabel,
1570+ return TVar {tvarId, tvarLabel,
15711571 tvarCurrent, tvarUndo, tvarBlocked, tvarVClock,
15721572 tvarTrace}
15731573
0 commit comments