dejafu-1.0.0.0: A library for unit-testing concurrent programs.

Copyright (c) 2017 Michael Walker MIT Michael Walker experimental portable None Haskell2010

Test.DejaFu.Internal

Description

Internal types and functions used throughout DejaFu. This module is NOT considered to form part of the public interface of this library.

Synopsis

# Identifiers

data IdSource Source #

The number of ID parameters was getting a bit unwieldy, so this hides them all away.

Constructors

 IdSource Fields_crids :: (Int, [String]) _mvids :: (Int, [String]) _tvids :: (Int, [String]) _tids :: (Int, [String])

Instances

 Source # Methods Source # Methods(<) :: IdSource -> IdSource -> Bool #(>) :: IdSource -> IdSource -> Bool # Source # MethodsshowList :: [IdSource] -> ShowS # Source # Methodsrnf :: IdSource -> () #

Get the next free CRefId.

Get the next free MVarId.

Get the next free TVarId.

Get the next free ThreadId.

nextId :: String -> (Int, [String]) -> (Id, (Int, [String])) Source #

Helper for next*

The initial ID source.

# Actions

Check if a ThreadAction immediately blocks.

Get the TVars affected by a ThreadAction.

Get the TVars a transaction wrote to (or would have, if it didn't retry).

Get the TVars a transaction read from.

Convert a ThreadAction into a Lookahead: "rewind" what has happened. Killed has no Lookahead counterpart.

Check if an operation could enable another thread.

# Simplified actions

A simplified view of the possible actions a thread can perform.

Constructors

 UnsynchronisedRead CRefId A readCRef or a readForCAS. UnsynchronisedWrite CRefId A writeCRef. UnsynchronisedOther Some other action which doesn't require cross-thread communication. PartiallySynchronisedCommit CRefId A commit. PartiallySynchronisedWrite CRefId A casCRef PartiallySynchronisedModify CRefId A modifyCRefCAS SynchronisedModify CRefId An atomicModifyCRef. SynchronisedRead MVarId A readMVar or takeMVar (or try/blocked variants). SynchronisedWrite MVarId A putMVar (or try/blocked variant). SynchronisedOther Some other action which does require cross-thread communication.

Instances

 Source # Methods Source # MethodsshowList :: [ActionType] -> ShowS # Source # Methodsrnf :: ActionType -> () #

Check if an action imposes a write barrier.

Check if an action commits a given CRef.

Check if an action synchronises a given CRef.

Get the CRef affected.

Get the MVar affected.

Throw away information from a ThreadAction and give a simplified view of what is happening.

This is used in the SCT code to help determine interesting alternative scheduling decisions.

Variant of simplifyAction that takes a Lookahead.

# Error reporting

ehead :: String -> [a] -> a Source #

head but with a better error message if it fails. Use this only where it shouldn't fail!

etail :: String -> [a] -> [a] Source #

tail but with a better error message if it fails. Use this only where it shouldn't fail!

eidx :: String -> [a] -> Int -> a Source #

'(!!)' but with a better error message if it fails. Use this only where it shouldn't fail!

efromJust :: String -> Maybe a -> a Source #

fromJust but with a better error message if it fails. Use this only where it shouldn't fail!

efromList :: String -> [a] -> NonEmpty a Source #

fromList but with a better error message if it fails. Use this only where it shouldn't fail!

fatal :: String -> String -> a Source #

error but saying where it came from

# Miscellaneous

runRefCont :: MonadRef r n => (n () -> x) -> (a -> Maybe b) -> ((a -> x) -> x) -> n (x, r (Maybe b)) Source #

Run with a continuation that writes its value into a reference, returning the computation and the reference. Using the reference is non-blocking, it is up to you to ensure you wait sufficiently.