@@ -205,22 +205,22 @@ initialState =
205
205
where
206
206
epoch1970 = UTCTime (fromGregorian 1970 1 1 ) 0
207
207
208
- invariant :: Maybe (Thread s a ) -> SimState s a -> Bool
208
+ invariant :: Maybe (Thread s a ) -> SimState s a -> x -> x
209
209
210
210
invariant (Just running) simstate@ SimState {runqueue,threads,clocks} =
211
- not (threadBlocked running)
212
- && threadId running `Map.notMember` threads
213
- && threadId running `List.notElem` runqueue
214
- && threadClockId running `Map.member` clocks
215
- && invariant Nothing simstate
211
+ assert ( not (threadBlocked running) )
212
+ . assert ( threadId running `Map.notMember` threads)
213
+ . assert ( threadId running `List.notElem` runqueue)
214
+ . assert ( threadClockId running `Map.member` clocks)
215
+ . invariant Nothing simstate
216
216
217
217
invariant Nothing SimState {runqueue,threads,clocks} =
218
- all (`Map.member` threads) runqueue
219
- && and [ (threadBlocked t || threadDone t) == (threadId t `notElem` runqueue)
220
- | t <- Map. elems threads ]
221
- && and (zipWith (>) runqueue (drop 1 runqueue))
222
- && and [ threadClockId t `Map.member` clocks
223
- | t <- Map. elems threads ]
218
+ assert ( all (`Map.member` threads) runqueue)
219
+ . assert ( and [ (threadBlocked t || threadDone t) == (threadId t `notElem` runqueue)
220
+ | t <- Map. elems threads ])
221
+ . assert ( and (zipWith (>) runqueue (drop 1 runqueue) ))
222
+ . assert ( and [ threadClockId t `Map.member` clocks
223
+ | t <- Map. elems threads ])
224
224
225
225
-- | Interpret the simulation monotonic time as a 'NominalDiffTime' since
226
226
-- the start.
@@ -274,7 +274,7 @@ schedule thread@Thread{
274
274
deschedule Sleep thread simstate
275
275
276
276
| otherwise =
277
- assert ( invariant (Just thread) simstate) $
277
+ invariant (Just thread) simstate $
278
278
case control of
279
279
ControlFollow (s: _) _ ->
280
280
id -- Debug.trace ("Performing action in step "++show s++"\n")
@@ -777,7 +777,7 @@ reschedule simstate@SimState{ runqueue, threads,
777
777
} =
778
778
assert (tid `elem` runqueue) $
779
779
assert (tid `Map.member` threads) $
780
- assert ( invariant Nothing simstate) $
780
+ invariant Nothing simstate $
781
781
let thread = threads Map. ! tid in
782
782
assert (threadId thread == tid) $
783
783
-- assert (threadStep thread == tstep) $
@@ -794,7 +794,7 @@ reschedule simstate@SimState{ runqueue, threads,
794
794
-- When there is no current running thread but the runqueue is non-empty then
795
795
-- schedule the next one to run.
796
796
reschedule simstate@ SimState { runqueue = tid: runqueue', threads } =
797
- assert ( invariant Nothing simstate) $
797
+ invariant Nothing simstate $
798
798
799
799
let thread = threads Map. ! tid in
800
800
schedule thread simstate { runqueue = runqueue'
@@ -803,7 +803,7 @@ reschedule simstate@SimState{ runqueue = tid:runqueue', threads } =
803
803
-- But when there are no runnable threads, we advance the time to the next
804
804
-- timer event, or stop.
805
805
reschedule simstate@ SimState { runqueue = [] , threads, timers, curTime = time, races } =
806
- assert ( invariant Nothing simstate) $
806
+ invariant Nothing simstate $
807
807
808
808
-- time is moving on
809
809
-- Debug.trace ("Rescheduling at "++show time++", "++
0 commit comments