예제 #1
0
        public async Task <CopySchedulerResult <CopyFileResult> > ScheduleOutboundPullAsync(OutboundPullCopy request)
        {
            return(await _outboundPullGate.GatedOperationAsync(async pair =>
            {
                var(timeWaiting, currentCount) = pair;

                var queueLength = _outboundPullGate.ConcurrencyLimit - currentCount;
                var summary = new CopySchedulingSummary(
                    QueueWait: timeWaiting,
                    PriorityQueueLength: queueLength,
                    Priority: 0,
                    OverallQueueLength: queueLength);

                return new CopySchedulerResult <CopyFileResult>(await request.PerformOperationAsync(new OutboundPullArguments(request.Context, summary)));
            },
                                                               request.Context.Token,
                                                               _configuration.OutboundPullConfiguration.WaitTimeout,
                                                               onTimeout : _ => CopySchedulerResult <CopyFileResult> .TimeOut()));
        }
예제 #2
0
        public Task<CopySchedulerResult<T>> ScheduleOutboundPushAsync<T>(OutboundPushCopy<T> request)
            where T : class
        {
            return _outboundPushGate.GatedOperationAsync(async pair =>
                {
                    var (timeWaiting, currentCount) = pair;

                    var queueLength = _outboundPushGate.ConcurrencyLimit - currentCount;
                    var summary = new CopySchedulingSummary(
                        QueueWait: timeWaiting,
                        PriorityQueueLength: queueLength,
                        Priority: 0,
                        OverallQueueLength: queueLength);

                    return new CopySchedulerResult<T>(await request.PerformOperationAsync(new OutboundPushArguments(request.Context, summary)));
                },
                request.Context.Token,
                _configuration.OutboundPushConfiguration.WaitTimeout,
                onTimeout: _ => CopySchedulerResult<T>.TimeOut(_configuration.OutboundPushConfiguration.WaitTimeout));
        }