Beispiel #1
0
 /// <summary>
 /// Reserves the specified request. Removes it from availability, but not from the pool. This is typically an intermediate state held during resource negotiation.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns><c>true</c> if the resource was successfully reserved, <c>false</c> otherwise.</returns>
 public bool Reserve(IResourceRequest request)
 {
     ResourceRequested?.Invoke(request, this);
     RequestEvent?.Invoke(request, this);
     lock (this) {
         if (AttemptExecution(request))
         {
             ReservedEvent?.Invoke(request, this);
             ResourceReserved?.Invoke(request, this);
             return(true);
         }
         return(false);
     }
 }
Beispiel #2
0
        public bool Reserve(IResourceRequest request)
        {
            IResource originator = m_wrappedByWhom ?? this;

            RequestEvent?.Invoke(request, originator);
            bool bSuccess;

            lock (this) {
                bSuccess = AttemptRemovalFromService(request);
                if (bSuccess)
                {
                    ReservedEvent?.Invoke(request, originator);
                }
            }
            return(bSuccess);
        }