Revision f066e7fb

b/src/Ganeti/Locking/Allocation.hs
29 29
  , OwnerState(..)
30 30
  , lockOwners
31 31
  , listLocks
32
  , holdsLock
32 33
  , LockRequest(..)
33 34
  , requestExclusive
34 35
  , requestShared
......
125 126
listLocks :: Ord b => b -> LockAllocation a b -> M.Map a OwnerState
126 127
listLocks owner = fromMaybe M.empty . M.lookup owner . laOwned
127 128

  
129
-- | Returns 'True' if the given owner holds the given lock at the given
130
-- ownership level or higher. This means that querying for a shared lock
131
-- returns 'True' of the owner holds the lock in shared or exlusive mode.
132
holdsLock :: (Ord a, Ord b)
133
          => b -> a -> OwnerState -> LockAllocation a b -> Bool
134
holdsLock owner lock state = (>= Just state) . M.lookup lock . listLocks owner
135

  
128 136
-- | Data Type describing a change request on a single lock.
129 137
data LockRequest a = LockRequest { lockAffected :: a
130 138
                                 , lockRequestType :: Maybe OwnerState

Also available in: Unified diff