Skip to content

Commit b0b02fd

Browse files
committed
io-sim-por: optimise thread termination
1 parent 3681605 commit b0b02fd

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ reschedule simstate@SimState{ runqueue, threads,
840840
-- When there is no current running thread but the runqueue is non-empty then
841841
-- schedule the next one to run.
842842
reschedule simstate@SimState{ runqueue, threads }
843-
| Just (Down tid, _, _, runqueue') <- PSQ.minView runqueue =
843+
| Just (Down !tid, _, _, runqueue') <- PSQ.minView runqueue =
844844
invariant Nothing simstate $
845845

846846
let thread = threads Map.! tid in
@@ -910,24 +910,24 @@ unblockThreads vClock wakeup simstate@SimState {runqueue, threads} =
910910
where
911911
-- can only unblock if the thread exists and is blocked (not running)
912912
unblocked :: [Thread s a]
913-
unblocked = [ thread
914-
| tid <- wakeup
915-
, thread <-
916-
case Map.lookup tid threads of
917-
Just Thread { threadDone = True } -> [ ]
918-
Just t@Thread { threadBlocked = True } -> [t]
919-
_ -> [ ]
920-
]
913+
!unblocked = [ thread
914+
| tid <- wakeup
915+
, thread <-
916+
case Map.lookup tid threads of
917+
Just Thread { threadDone = True } -> [ ]
918+
Just t@Thread { threadBlocked = True } -> [t]
919+
_ -> [ ]
920+
]
921921

922922
unblockedIds :: [ThreadId]
923-
unblockedIds = map threadId unblocked
923+
!unblockedIds = map threadId unblocked
924924

925925
-- and in which case we mark them as now running
926-
threads' = List.foldl'
927-
(flip (Map.adjust
928-
(\t -> t { threadBlocked = False,
929-
threadVClock = vClock `leastUpperBoundVClock` threadVClock t })))
930-
threads unblockedIds
926+
!threads' = List.foldl'
927+
(flip (Map.adjust
928+
(\t -> t { threadBlocked = False,
929+
threadVClock = vClock `leastUpperBoundVClock` threadVClock t })))
930+
threads unblockedIds
931931

932932

933933
-- | Iterate through the control stack to find an enclosing exception handler

0 commit comments

Comments
 (0)