...so that jobs can wait till they get a number of locks
that might work at least in principle.

Signed-off-by: Klaus Aehlig <[email protected]>
Reviewed-by: Hrvoje Ribicic <[email protected]>

Cherry-picked from 280f37bccdc676aec4e6e5aaf7e321632b12756b.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 src/Ganeti/WConfd/Core.hs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/Ganeti/WConfd/Core.hs b/src/Ganeti/WConfd/Core.hs
index 330a4f9..7b06fc8 100644
--- a/src/Ganeti/WConfd/Core.hs
+++ b/src/Ganeti/WConfd/Core.hs
@@ -292,6 +292,15 @@ opportunisticLockUnion :: ClientId
 opportunisticLockUnion cid req =
   modifyLockWaiting $ LW.opportunisticLockUnion cid req
 
+-- | Opprtunistially allocate locks for a given owner, requesting a
+-- certain minimum of success.
+guardedOpportunisticLockUnion :: Int
+                                 -> ClientId
+                                 -> [(GanetiLocks, L.OwnerState)]
+                                 -> WConfdMonad [GanetiLocks]
+guardedOpportunisticLockUnion count cid req =
+  modifyLockWaiting $ LW.guardedOpportunisticLockUnion count cid req
+
 -- * The list of all functions exported to RPC.
 
 exportedFunctions :: [Name]
@@ -335,5 +344,6 @@ exportedFunctions = [ 'echo
                     , 'downGradeLocksLevel
                     , 'intersectLocks
                     , 'opportunisticLockUnion
+                    , 'guardedOpportunisticLockUnion
                     , 'hasPendingRequest
                     ]
-- 
2.0.0.526.g5318336

Reply via email to