Commit b2a8f6ac authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add a function to get a LockWaiting from an extRepr



Add a function to obtain some lock waiting structure from a
given extensional representation.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 7fe8baad
......@@ -35,6 +35,7 @@ module Ganeti.Locking.Waiting
, releaseResources
, getPendingRequests
, extRepr
, fromExtRepr
) where
import Control.Arrow ((&&&))
......@@ -237,3 +238,12 @@ releaseResources owner state =
. M.keys . L.listLocks owner $ getAllocation state'
(state'', (_, notify)) = updateLocks owner request state'
in (state'', notify)
-- | Obtain a LockWaiting from its extensional representation.
fromExtRepr :: (Lock a, Ord b, Ord c)
=> ExtWaiting a b c -> LockWaiting a b c
fromExtRepr (alloc, pending) =
S.foldl (\s (prio, owner, req) ->
fst $ updateLocksWaiting prio owner req s)
(emptyWaiting { lwAllocation = alloc })
pending
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment