mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-11-05 06:45:08 +03:00
Do not export Decision, NonEmpty, tidOf, or decisionOf from Schedule
This commit is contained in:
parent
f310c60bc5
commit
dfd9017861
@ -81,10 +81,19 @@ This project is versioned according to the [Package Versioning Policy](https://p
|
||||
chosen thread is no longer in the list of alternatives, which makes raw traces easier to
|
||||
read. (#121)
|
||||
|
||||
- Due to changes in Test.DejaFu.Schedule, no longer re-exports `Decision`, `NonEmpty`, `tidOf`, or
|
||||
`decisionOf`.
|
||||
|
||||
### Test.DejaFu.Refinement
|
||||
|
||||
- A blocking interference function is no longer reported as a deadlocking execution.
|
||||
|
||||
### Test.DejaFu.Schedule
|
||||
|
||||
- No longer re-exports `Decision` or `NonEmpty`.
|
||||
|
||||
- The `tidOf` and `decisionOf` functions have moved to Test.DejaFu.Utils.
|
||||
|
||||
### Test.DejaFu.SCT
|
||||
|
||||
- All testing functions now require a `MonadConc` constraint:
|
||||
|
@ -121,6 +121,7 @@ import Test.DejaFu.Conc
|
||||
import Test.DejaFu.Internal
|
||||
import Test.DejaFu.SCT.Internal
|
||||
import Test.DejaFu.Types
|
||||
import Test.DejaFu.Utils
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Running Concurrent Programs
|
||||
|
@ -31,8 +31,9 @@ import qualified Data.Set as S
|
||||
import System.Random (RandomGen, randomR)
|
||||
|
||||
import Test.DejaFu.Internal
|
||||
import Test.DejaFu.Schedule (Scheduler(..), decisionOf, tidOf)
|
||||
import Test.DejaFu.Schedule (Scheduler(..))
|
||||
import Test.DejaFu.Types
|
||||
import Test.DejaFu.Utils (decisionOf, tidOf)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- * Dynamic partial-order reduction
|
||||
|
@ -11,12 +11,6 @@ module Test.DejaFu.Schedule
|
||||
( -- * Scheduling
|
||||
Scheduler(..)
|
||||
|
||||
, Decision(..)
|
||||
, tidOf
|
||||
, decisionOf
|
||||
|
||||
, NonEmpty(..)
|
||||
|
||||
-- ** Preemptive
|
||||
, randomSched
|
||||
, roundRobinSched
|
||||
@ -57,37 +51,6 @@ newtype Scheduler state = Scheduler
|
||||
-> (Maybe ThreadId, state)
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Scheduling decisions
|
||||
|
||||
-- | Get the resultant thread identifier of a 'Decision', with a default case
|
||||
-- for 'Continue'.
|
||||
--
|
||||
-- @since 0.5.0.0
|
||||
tidOf :: ThreadId -> Decision -> ThreadId
|
||||
tidOf _ (Start t) = t
|
||||
tidOf _ (SwitchTo t) = t
|
||||
tidOf tid _ = tid
|
||||
|
||||
-- | Get the 'Decision' that would have resulted in this thread
|
||||
-- identifier, given a prior thread (if any) and collection of threads
|
||||
-- which are unblocked at this point.
|
||||
--
|
||||
-- @since 0.5.0.0
|
||||
decisionOf :: Foldable f
|
||||
=> Maybe ThreadId
|
||||
-- ^ The prior thread.
|
||||
-> f ThreadId
|
||||
-- ^ The threads.
|
||||
-> ThreadId
|
||||
-- ^ The current thread.
|
||||
-> Decision
|
||||
decisionOf Nothing _ chosen = Start chosen
|
||||
decisionOf (Just prior) runnable chosen
|
||||
| prior == chosen = Continue
|
||||
| prior `elem` runnable = SwitchTo chosen
|
||||
| otherwise = Start chosen
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Preemptive
|
||||
|
||||
|
@ -16,6 +16,9 @@ import Data.Ord (comparing)
|
||||
|
||||
import Test.DejaFu.Types
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- * Traces
|
||||
|
||||
-- | Pretty-print a trace, including a key of the thread IDs (not
|
||||
-- including thread 0). Each line of the key is indented by two
|
||||
-- spaces.
|
||||
@ -46,17 +49,6 @@ threadNames = mapMaybe go where
|
||||
go (_, _, ForkOS (ThreadId (Id (Just name) i))) = Just (i, name)
|
||||
go _ = Nothing
|
||||
|
||||
-- | Pretty-print a failure
|
||||
--
|
||||
-- @since 0.4.0.0
|
||||
showFail :: Failure -> String
|
||||
showFail Abort = "[abort]"
|
||||
showFail Deadlock = "[deadlock]"
|
||||
showFail STMDeadlock = "[stm-deadlock]"
|
||||
showFail InternalError = "[internal-error]"
|
||||
showFail (UncaughtException exc) = "[" ++ displayException exc ++ "]"
|
||||
showFail IllegalSubconcurrency = "[illegal-subconcurrency]"
|
||||
|
||||
-- | Find the \"simplest\" trace leading to each result.
|
||||
simplestsBy :: (x -> x -> Bool) -> [(x, Trace)] -> [(x, Trace)]
|
||||
simplestsBy f = map choose . collect where
|
||||
@ -75,3 +67,48 @@ simplestsBy f = map choose . collect where
|
||||
| x `eq` y = (x:ys) : yss
|
||||
| otherwise = ys : insert' eq x yss
|
||||
insert' _ _ ([]:_) = undefined
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- * Failures
|
||||
|
||||
-- | Pretty-print a failure
|
||||
--
|
||||
-- @since 0.4.0.0
|
||||
showFail :: Failure -> String
|
||||
showFail Abort = "[abort]"
|
||||
showFail Deadlock = "[deadlock]"
|
||||
showFail STMDeadlock = "[stm-deadlock]"
|
||||
showFail InternalError = "[internal-error]"
|
||||
showFail (UncaughtException exc) = "[" ++ displayException exc ++ "]"
|
||||
showFail IllegalSubconcurrency = "[illegal-subconcurrency]"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- * Scheduling
|
||||
|
||||
-- | Get the resultant thread identifier of a 'Decision', with a default case
|
||||
-- for 'Continue'.
|
||||
--
|
||||
-- @since 0.5.0.0
|
||||
tidOf :: ThreadId -> Decision -> ThreadId
|
||||
tidOf _ (Start t) = t
|
||||
tidOf _ (SwitchTo t) = t
|
||||
tidOf tid _ = tid
|
||||
|
||||
-- | Get the 'Decision' that would have resulted in this thread
|
||||
-- identifier, given a prior thread (if any) and collection of threads
|
||||
-- which are unblocked at this point.
|
||||
--
|
||||
-- @since 0.5.0.0
|
||||
decisionOf :: Foldable f
|
||||
=> Maybe ThreadId
|
||||
-- ^ The prior thread.
|
||||
-> f ThreadId
|
||||
-- ^ The threads.
|
||||
-> ThreadId
|
||||
-- ^ The current thread.
|
||||
-> Decision
|
||||
decisionOf Nothing _ chosen = Start chosen
|
||||
decisionOf (Just prior) runnable chosen
|
||||
| prior == chosen = Continue
|
||||
| prior `elem` runnable = SwitchTo chosen
|
||||
| otherwise = Start chosen
|
||||
|
Loading…
Reference in New Issue
Block a user