Revision e227f161
b/src/Ganeti/Locking/Allocation.hs | ||
---|---|---|
35 | 35 |
, requestRelease |
36 | 36 |
, updateLocks |
37 | 37 |
, freeLocks |
38 |
, freeLocksPredicate |
|
38 | 39 |
, intersectLocks |
39 | 40 |
, opportunisticLockUnion |
40 | 41 |
) where |
... | ... | |
292 | 293 |
state'' = foldl (updateIndirects owner) state' reqs |
293 | 294 |
return (if S.null blocked then state'' else state, blocked) |
294 | 295 |
|
296 |
-- | Compute the state after an owner releases all its locks that |
|
297 |
-- satisfy a certain property. |
|
298 |
freeLocksPredicate :: (Lock a, Ord b) |
|
299 |
=> (a -> Bool) |
|
300 |
-> LockAllocation a b -> b -> LockAllocation a b |
|
301 |
freeLocksPredicate property state owner = |
|
302 |
fst . flip (updateLocks owner) state . map requestRelease |
|
303 |
. filter property |
|
304 |
. M.keys |
|
305 |
$ listLocks owner state |
|
306 |
|
|
295 | 307 |
-- | Compute the state after an onwer releases all its locks. |
296 | 308 |
freeLocks :: (Lock a, Ord b) => LockAllocation a b -> b -> LockAllocation a b |
297 |
freeLocks state owner = |
|
298 |
fst . flip (updateLocks owner) state . map requestRelease . M.keys |
|
299 |
$ listLocks owner state |
|
309 |
freeLocks = freeLocksPredicate (const True) |
|
300 | 310 |
|
301 | 311 |
-- | Restrict the locks of a user to a given set. |
302 | 312 |
intersectLocks :: (Lock a, Ord b) => b -> [a] |
Also available in: Unified diff