mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-12-20 03:51:39 +03:00
Un-break detection of global deadlock
This commit is contained in:
parent
4a69fde83e
commit
14b08ff026
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user