/// <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); } }
public void On(ResourceReserved e) { this.Reservations.Add(new Reservation(e.RequestId, e.Interval)); }
public Task HandleAsync(ResourceReserved @event) => _coordinator.ProcessAsync(@event, SagaContext.Empty);