LGTM

On Tue, Apr 8, 2014 at 2:02 PM, Klaus Aehlig <[email protected]> wrote:

> Add a convenience function---definable from the exported
> interface---to clean up all the resources of an owner. This
> will be needed, e.g., if a job dies.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Locking/Waiting.hs | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/src/Ganeti/Locking/Waiting.hs b/src/Ganeti/Locking/Waiting.hs
> index 4079db2..e062b44 100644
> --- a/src/Ganeti/Locking/Waiting.hs
> +++ b/src/Ganeti/Locking/Waiting.hs
> @@ -31,6 +31,7 @@ module Ganeti.Locking.Waiting
>   , getAllocation
>   , getPendingOwners
>   , removePendingRequest
> + , releaseResources
>   ) where
>
>  import qualified Data.Map as M
> @@ -203,3 +204,15 @@ removePendingRequest owner state =
>        in state { lwPendingOwners = M.delete owner pendingOwners
>                 , lwPending = pending'
>                 }
> +
> +-- | Convenience function to release all pending requests and locks
> +-- of a given owner. Return the new configuration and the owners to
> +-- notify.
> +releaseResources :: (Lock a, Ord b, Ord c)
> +                 => b -> LockWaiting a b c -> (LockWaiting a b c, S.Set b)
> +releaseResources owner state =
> +  let state' = removePendingRequest owner state
> +      request = map L.requestRelease
> +                  . M.keys . L.listLocks owner $ getAllocation state'
> +      (state'', (_, notify)) = updateLocks owner request state'
> +  in (state'', notify)
> --
> 1.9.1.423.g4596e3a
>
>

Reply via email to