@@ -289,37 +289,37 @@ schedule !thread@Thread{
289
289
schedule thread' simstate
290
290
291
291
GetWallTime k -> do
292
- let clockid = threadClockId thread
293
- clockoff = clocks Map. ! clockid
294
- walltime = timeSinceEpoch time `addUTCTime` clockoff
295
- thread' = thread { threadControl = ThreadControl (k walltime) ctl }
292
+ let ! clockid = threadClockId thread
293
+ ! clockoff = clocks Map. ! clockid
294
+ ! walltime = timeSinceEpoch time `addUTCTime` clockoff
295
+ ! thread' = thread { threadControl = ThreadControl (k walltime) ctl }
296
296
schedule thread' simstate
297
297
298
298
SetWallTime walltime' k -> do
299
- let clockid = threadClockId thread
300
- clockoff = clocks Map. ! clockid
301
- walltime = timeSinceEpoch time `addUTCTime` clockoff
302
- clockoff' = addUTCTime (diffUTCTime walltime' walltime) clockoff
303
- thread' = thread { threadControl = ThreadControl k ctl }
304
- simstate' = simstate { clocks = Map. insert clockid clockoff' clocks }
299
+ let ! clockid = threadClockId thread
300
+ ! clockoff = clocks Map. ! clockid
301
+ ! walltime = timeSinceEpoch time `addUTCTime` clockoff
302
+ ! clockoff' = addUTCTime (diffUTCTime walltime' walltime) clockoff
303
+ ! thread' = thread { threadControl = ThreadControl k ctl }
304
+ ! simstate' = simstate { clocks = Map. insert clockid clockoff' clocks }
305
305
schedule thread' simstate'
306
306
307
307
UnshareClock k -> do
308
- let clockid = threadClockId thread
309
- clockoff = clocks Map. ! clockid
310
- clockid' = let ThreadId i = tid in ClockId i -- reuse the thread id
311
- thread' = thread { threadControl = ThreadControl k ctl
312
- , threadClockId = clockid' }
313
- simstate' = simstate { clocks = Map. insert clockid' clockoff clocks }
308
+ let ! clockid = threadClockId thread
309
+ ! clockoff = clocks Map. ! clockid
310
+ ! clockid' = let ThreadId i = tid in ClockId i -- reuse the thread id
311
+ ! thread' = thread { threadControl = ThreadControl k ctl
312
+ , threadClockId = clockid' }
313
+ ! simstate' = simstate { clocks = Map. insert clockid' clockoff clocks }
314
314
schedule thread' simstate'
315
315
316
316
-- we treat negative timers as cancelled ones; for the record we put
317
317
-- `EventTimerCreated` and `EventTimerCancelled` in the trace; This differs
318
318
-- from `GHC.Event` behaviour.
319
319
NewTimeout d k | d < 0 -> do
320
- let t = NegativeTimeout nextTmid
321
- expiry = d `addTime` time
322
- thread' = thread { threadControl = ThreadControl (k t) ctl }
320
+ let ! t = NegativeTimeout nextTmid
321
+ ! expiry = d `addTime` time
322
+ ! thread' = thread { threadControl = ThreadControl (k t) ctl }
323
323
trace <- schedule thread' simstate { nextTmid = succ nextTmid }
324
324
return (SimTrace time tid tlbl (EventTimerCreated nextTmid nextVid expiry) $
325
325
SimTrace time tid tlbl (EventTimerCancelled nextTmid) $
@@ -332,10 +332,10 @@ schedule !thread@Thread{
332
332
! tvar' <- execNewTVar (succ nextVid)
333
333
(Just $ " <<timeout " ++ show (unTimeoutId nextTmid) ++ " >>" )
334
334
False
335
- let expiry = d `addTime` time
336
- t = Timeout tvar tvar' nextTmid
337
- timers' = PSQ. insert nextTmid expiry (TimerVars tvar tvar') timers
338
- thread' = thread { threadControl = ThreadControl (k t) ctl }
335
+ let ! expiry = d `addTime` time
336
+ ! t = Timeout tvar tvar' nextTmid
337
+ ! timers' = PSQ. insert nextTmid expiry (TimerVars tvar tvar') timers
338
+ ! thread' = thread { threadControl = ThreadControl (k t) ctl }
339
339
trace <- schedule thread' simstate { timers = timers'
340
340
, nextVid = succ (succ nextVid)
341
341
, nextTmid = succ nextTmid }
@@ -344,8 +344,8 @@ schedule !thread@Thread{
344
344
-- we do not follow `GHC.Event` behaviour here; updating a timer to the past
345
345
-- effectively cancels it.
346
346
UpdateTimeout (Timeout _tvar _tvar' tmid) d k | d < 0 -> do
347
- let timers' = PSQ. delete tmid timers
348
- thread' = thread { threadControl = ThreadControl k ctl }
347
+ let ! timers' = PSQ. delete tmid timers
348
+ ! thread' = thread { threadControl = ThreadControl k ctl }
349
349
trace <- schedule thread' simstate { timers = timers' }
350
350
return (SimTrace time tid tlbl (EventTimerCancelled tmid) trace)
351
351
@@ -354,9 +354,9 @@ schedule !thread@Thread{
354
354
-- to race using a timeout with updating or cancelling it
355
355
let updateTimeout_ Nothing = (() , Nothing )
356
356
updateTimeout_ (Just (_p, v)) = (() , Just (expiry, v))
357
- expiry = d `addTime` time
358
- timers' = snd (PSQ. alter updateTimeout_ tmid timers)
359
- thread' = thread { threadControl = ThreadControl k ctl }
357
+ ! expiry = d `addTime` time
358
+ ! timers' = snd (PSQ. alter updateTimeout_ tmid timers)
359
+ ! thread' = thread { threadControl = ThreadControl k ctl }
360
360
trace <- schedule thread' simstate { timers = timers' }
361
361
return (SimTrace time tid tlbl (EventTimerUpdated tmid expiry) trace)
362
362
@@ -366,8 +366,8 @@ schedule !thread@Thread{
366
366
schedule thread' simstate
367
367
368
368
CancelTimeout (Timeout tvar _tvar' tmid) k -> do
369
- let timers' = PSQ. delete tmid timers
370
- thread' = thread { threadControl = ThreadControl k ctl }
369
+ let ! timers' = PSQ. delete tmid timers
370
+ ! thread' = thread { threadControl = ThreadControl k ctl }
371
371
! written <- execAtomically' (runSTM $ writeTVar tvar TimeoutCancelled )
372
372
(! wakeup, wokeby) <- threadsUnblockedByWrites written
373
373
mapM_ (\ (SomeTVar var) -> unblockAllThreadsFromTVar var) written
@@ -389,21 +389,21 @@ schedule !thread@Thread{
389
389
schedule thread' simstate
390
390
391
391
Fork a k -> do
392
- let nextId = threadNextTId thread
393
- tid' = childThreadId tid nextId
394
- thread' = thread { threadControl = ThreadControl (k tid') ctl
395
- , threadNextTId = succ nextId }
396
- thread'' = Thread { threadId = tid'
397
- , threadControl = ThreadControl (runIOSim a)
398
- ForkFrame
399
- , threadBlocked = False
400
- , threadMasking = threadMasking thread
401
- , threadThrowTo = []
402
- , threadClockId = threadClockId thread
403
- , threadLabel = Nothing
404
- , threadNextTId = 1
405
- }
406
- threads' = Map. insert tid' thread'' threads
392
+ let ! nextId = threadNextTId thread
393
+ ! tid' = childThreadId tid nextId
394
+ ! thread' = thread { threadControl = ThreadControl (k tid') ctl
395
+ , threadNextTId = succ nextId }
396
+ ! thread'' = Thread { threadId = tid'
397
+ , threadControl = ThreadControl (runIOSim a)
398
+ ForkFrame
399
+ , threadBlocked = False
400
+ , threadMasking = threadMasking thread
401
+ , threadThrowTo = []
402
+ , threadClockId = threadClockId thread
403
+ , threadLabel = Nothing
404
+ , threadNextTId = 1
405
+ }
406
+ ! threads' = Map. insert tid' thread'' threads
407
407
trace <- schedule thread' simstate { runqueue = Deque. snoc tid' runqueue
408
408
, threads = threads' }
409
409
return (SimTrace time tid tlbl (EventThreadForked tid') trace)
0 commit comments