public void Calibrate() { if (_rules.Any(r => r.CanBeCalibrated)) { var request = QuotaRequest.Calibrate(); _reserveQueue.Add(request); } }
private Task <BoolResult> SendPurgeRequest(OperationContext context, string reason) { return(context.PerformOperationAsync( Tracer, () => { var emptyRequest = QuotaRequest.Purge(); _reserveQueue.Add(emptyRequest); return emptyRequest.CompletionAsync(); }, traceErrorsOnly: true)); }
private Task <BoolResult> SendPurgeRequest(OperationContext context, string reason) { return(context.PerformOperationAsync( _tracer, () => { var emptyRequest = QuotaRequest.Purge(); _reserveQueue.Add(emptyRequest); return emptyRequest.CompletionAsync(); }, extraStartMessage: $"Requesting purge due to '{reason}'.")); }
private Task <BoolResult> SendSyncRequest(OperationContext context, bool purge) { if (purge) { return(SendPurgeRequest(context, "Sync")); } return(context.PerformOperationAsync( Tracer, () => { var emptyRequest = QuotaRequest.Synchronize(); _reserveQueue.Add(emptyRequest); return emptyRequest.CompletionAsync(); })); }
public async Task <ReserveTransaction> ReserveAsync(long contentSize) { Contract.Assert(contentSize >= 0); ShutdownStartedCancellationToken.ThrowIfCancellationRequested(); var reserveRequest = QuotaRequest.Reserve(contentSize); // To avoid potential race condition need to increase size first and only after that to add the request into the queue. IncreaseSize(ref _requestedSize, reserveRequest.ReserveSize); _reserveQueue.Add(reserveRequest); BoolResult result = await reserveRequest.CompletionAsync(); if (!result) { throw new CacheException($"Failed to reserve space for content size=[{contentSize}], result=[{result}]"); } return(new ReserveTransaction(reserveRequest, OnReservationCommitted)); }