Un-break detection of global deadlock

This commit is contained in:
Michael Walker 2015-02-23 18:23:58 +00:00
parent 4a69fde83e
commit 14b08ff026

View File

@ -9,7 +9,7 @@ import Control.Exception (Exception, MaskingState(..), SomeException(..), fromEx
import Control.Monad.Cont (cont) import Control.Monad.Cont (cont)
import Data.List (intersect, nub) import Data.List (intersect, nub)
import Data.Map (Map) import Data.Map (Map)
import Data.Maybe (fromMaybe, isJust) import Data.Maybe (fromMaybe, isJust, isNothing)
import Test.DejaFu.STM (CTVarId) import Test.DejaFu.STM (CTVarId)
import Test.DejaFu.Deterministic.Internal.Common import Test.DejaFu.Deterministic.Internal.Common
@ -56,13 +56,14 @@ thread ~= theblock = case (_blocking thread, theblock) of
_ -> False _ -> False
-- | Determine if a thread is deadlocked. If at least one thread is -- | Determine if a thread is deadlocked. If at least one thread is
-- not in a fully-known state, this will return 'False'. -- not in a fully-known state, this will only check for global
-- deadlock.
isLocked :: ThreadId -> Threads n r a -> Bool isLocked :: ThreadId -> Threads n r a -> Bool
isLocked tid ts isLocked tid ts
| allKnown = case M.lookup tid ts of | allKnown = case M.lookup tid ts of
Just thread -> noRefs $ _blocking thread Just thread -> noRefs $ _blocking thread
Nothing -> False Nothing -> False
| otherwise = False | otherwise = M.null $ M.filter (isNothing . _blocking) ts
where where
-- | Check if all threads are in a fully-known state. -- | Check if all threads are in a fully-known state.