@@ -149,7 +149,7 @@ data SimState s a = SimState {
149
149
timers :: ! (Timeouts s ),
150
150
-- | list of clocks
151
151
clocks :: ! (Map ClockId UTCTime ),
152
- nextVid :: ! TVarId , -- ^ next unused 'TVarId '
152
+ nextVid :: ! VarId , -- ^ next unused 'VarId '
153
153
nextTmid :: ! TimeoutId -- ^ next unused 'TimeoutId'
154
154
}
155
155
@@ -161,7 +161,7 @@ initialState =
161
161
curTime = Time 0 ,
162
162
timers = PSQ. empty,
163
163
clocks = Map. singleton (ClockId [] ) epoch1970,
164
- nextVid = TVarId 0 ,
164
+ nextVid = 0 ,
165
165
nextTmid = TimeoutId 0
166
166
}
167
167
where
@@ -358,7 +358,7 @@ schedule !thread@Thread{
358
358
error " schedule: StartTimeout: Impossible happened"
359
359
360
360
StartTimeout d action' k -> do
361
- ! lock <- TMVar <$> execNewTVar nextVid (Just $! " lock-" ++ show nextTmid) Nothing
361
+ ! lock <- TMVar <$> execNewTVar ( TMVarId nextVid) (Just $! " lock-" ++ show nextTmid) Nothing
362
362
let ! expiry = d `addTime` time
363
363
! timers' = PSQ. insert nextTmid expiry (TimerTimeout tid nextTmid lock) timers
364
364
! thread' = thread { threadControl =
@@ -376,18 +376,18 @@ schedule !thread@Thread{
376
376
schedule thread' simstate { timers = PSQ. delete tmid timers }
377
377
378
378
RegisterDelay d k | d < 0 -> do
379
- ! tvar <- execNewTVar nextVid
379
+ ! tvar <- execNewTVar ( TVarId nextVid)
380
380
(Just $! " <<timeout " ++ show (unTimeoutId nextTmid) ++ " >>" )
381
381
True
382
382
let ! expiry = d `addTime` time
383
383
! thread' = thread { threadControl = ThreadControl (k tvar) ctl }
384
384
trace <- schedule thread' simstate { nextVid = succ nextVid }
385
- return (SimTrace time tid tlbl (EventRegisterDelayCreated nextTmid nextVid expiry) $
385
+ return (SimTrace time tid tlbl (EventRegisterDelayCreated nextTmid ( TVarId nextVid) expiry) $
386
386
SimTrace time tid tlbl (EventRegisterDelayFired nextTmid) $
387
387
trace)
388
388
389
389
RegisterDelay d k -> do
390
- ! tvar <- execNewTVar nextVid
390
+ ! tvar <- execNewTVar ( TVarId nextVid)
391
391
(Just $! " <<timeout " ++ show (unTimeoutId nextTmid) ++ " >>" )
392
392
False
393
393
let ! expiry = d `addTime` time
@@ -397,7 +397,7 @@ schedule !thread@Thread{
397
397
, nextVid = succ nextVid
398
398
, nextTmid = succ nextTmid }
399
399
return (SimTrace time tid tlbl
400
- (EventRegisterDelayCreated nextTmid nextVid expiry) trace)
400
+ (EventRegisterDelayCreated nextTmid ( TVarId nextVid) expiry) trace)
401
401
402
402
ThreadDelay d k | d < 0 -> do
403
403
let ! expiry = d `addTime` time
@@ -424,12 +424,12 @@ schedule !thread@Thread{
424
424
! expiry = d `addTime` time
425
425
! thread' = thread { threadControl = ThreadControl (k t) ctl }
426
426
trace <- schedule thread' simstate { nextTmid = succ nextTmid }
427
- return (SimTrace time tid tlbl (EventTimerCreated nextTmid nextVid expiry) $
427
+ return (SimTrace time tid tlbl (EventTimerCreated nextTmid ( TVarId nextVid) expiry) $
428
428
SimTrace time tid tlbl (EventTimerCancelled nextTmid) $
429
429
trace)
430
430
431
431
NewTimeout d k -> do
432
- ! tvar <- execNewTVar nextVid
432
+ ! tvar <- execNewTVar ( TVarId nextVid)
433
433
(Just $! " <<timeout-state " ++ show (unTimeoutId nextTmid) ++ " >>" )
434
434
TimeoutPending
435
435
let ! expiry = d `addTime` time
@@ -439,7 +439,7 @@ schedule !thread@Thread{
439
439
trace <- schedule thread' simstate { timers = timers'
440
440
, nextVid = succ nextVid
441
441
, nextTmid = succ nextTmid }
442
- return (SimTrace time tid tlbl (EventTimerCreated nextTmid nextVid expiry) trace)
442
+ return (SimTrace time tid tlbl (EventTimerCreated nextTmid ( TVarId nextVid) expiry) trace)
443
443
444
444
CancelTimeout (Timeout tvar tmid) k -> do
445
445
let ! timers' = PSQ. delete tmid timers
@@ -1030,7 +1030,7 @@ execAtomically :: forall s a c.
1030
1030
Time
1031
1031
-> IOSimThreadId
1032
1032
-> Maybe ThreadLabel
1033
- -> TVarId
1033
+ -> VarId
1034
1034
-> StmA s a
1035
1035
-> (StmTxResult s a -> ST s (SimTrace c ))
1036
1036
-> ST s (SimTrace c )
@@ -1043,7 +1043,7 @@ execAtomically !time !tid !tlbl !nextVid0 !action0 !k0 =
1043
1043
-> Map TVarId (SomeTVar s ) -- set of vars written
1044
1044
-> [SomeTVar s ] -- vars written in order (no dups)
1045
1045
-> [SomeTVar s ] -- vars created in order
1046
- -> TVarId -- var fresh name supply
1046
+ -> VarId -- var fresh name supply
1047
1047
-> StmA s b
1048
1048
-> ST s (SimTrace c )
1049
1049
go ! ctl ! read ! written ! writtenSeq ! createdSeq ! nextVid ! action =
@@ -1145,8 +1145,8 @@ execAtomically !time !tid !tlbl !nextVid0 !action0 !k0 =
1145
1145
let ctl' = BranchFrame (OrElseStmA b) k written writtenSeq createdSeq ctl
1146
1146
go ctl' read Map. empty [] [] nextVid a
1147
1147
1148
- NewTVar ! mbLabel x k -> do
1149
- ! v <- execNewTVar nextVid mbLabel x
1148
+ NewTVar mkId ! mbLabel x k -> do
1149
+ ! v <- execNewTVar (mkId nextVid) mbLabel x
1150
1150
go ctl read written writtenSeq (SomeTVar v : createdSeq) (succ nextVid) (k v)
1151
1151
1152
1152
LabelTVar ! label tvar k -> do
@@ -1229,14 +1229,14 @@ execAtomically' = go Map.empty
1229
1229
1230
1230
1231
1231
execNewTVar :: TVarId -> Maybe String -> a -> ST s (TVar s a )
1232
- execNewTVar nextVid ! mbLabel x = do
1232
+ execNewTVar ! tvarId ! mbLabel x = do
1233
1233
! tvarLabel <- newSTRef mbLabel
1234
1234
! tvarCurrent <- newSTRef x
1235
1235
! tvarUndo <- newSTRef $! []
1236
1236
! tvarBlocked <- newSTRef ([] , Set. empty)
1237
1237
! tvarVClock <- newSTRef $! VectorClock Map. empty
1238
1238
! tvarTrace <- newSTRef $! Nothing
1239
- return TVar {tvarId = nextVid , tvarLabel,
1239
+ return TVar {tvarId, tvarLabel,
1240
1240
tvarCurrent, tvarUndo, tvarBlocked, tvarVClock,
1241
1241
tvarTrace}
1242
1242
0 commit comments