Revision d8216f2d

b/src/Ganeti/Locking/Allocation.hs
34 34
  , requestRelease
35 35
  , updateLocks
36 36
  , freeLocks
37
  , intersectLocks
37 38
  ) where
38 39

  
39 40
import Control.Arrow (second, (***))
......
285 286
freeLocks state owner =
286 287
  fst . flip (updateLocks owner) state . map requestRelease . M.keys
287 288
    $ listLocks owner state
289

  
290
-- | Restrict the locks of a user to a given set.
291
intersectLocks :: (Lock a, Ord b) => b -> [a]
292
               -> LockAllocation a b -> LockAllocation a b
293
intersectLocks owner locks state =
294
  let lockset = S.fromList locks
295
      toFree = filter (not . flip S.member lockset)
296
                 . M.keys $ listLocks owner state
297
  in fst $ updateLocks owner (map requestRelease toFree) state

Also available in: Unified diff