public ScheduleParallelLimit(IQueueWorker queue, ICounterBlocked processCount, TimeSpan timeLimit, int limit, IWorkerHandler workerHandler)
            : base(queue, processCount, timeLimit, workerHandler)
        {
            limit = limit <= 0 ? 5 : limit;

            _threadLimit = new SemaphoreSlim(limit, limit);
        }
示例#2
0
        public InternalWorkerDataSync(IActionInvoker <TData> actionInvoker, ICounterBlocked counterBlocked)
        {
            counterBlocked.Increment();

            _actionInvoker  = actionInvoker;
            _counterBlocked = counterBlocked;
        }
示例#3
0
 public DefaultWorkerRunner(ICounterBlocked counterBlocked, IWorkerHandler workerHandler, TimeSpan timeLimit, IWorkerNotify queueWorker)
 {
     _counterBlocked = counterBlocked;
     _workerHandler  = workerHandler;
     _timeLimit      = timeLimit;
     _queueWorker    = queueWorker;
 }
 public ScheduleStrategiesBase(IQueueWorker queueWorker, ICounterBlocked processCount, TimeSpan timeLimit, IWorkerHandler workerHandler)
 {
     _processCount = processCount;
     _timeLimit    = timeLimit;
     _handler      = workerHandler;
     _queueWorker  = queueWorker;
     _workerRunner = CreateWorkerRunner(_processCount, workerHandler, _timeLimit);
 }
        internal DispatcherToken(ICounterBlocked counterProcess,
                                 IQueueWorker queueWorker,
                                 ActionDispatcherSettings actionDispatcherSettings,
                                 CancellationTokenSource cancellationTokenSource,
                                 ICounterBlocked chainCounterBlocked,
                                 IWorkerHandler workerHandler)
        {
            _processCount = counterProcess;

            _chainCounter  = chainCounterBlocked;
            _workerHandler = workerHandler;
            _queueWorker   = queueWorker;

            _cancellationTokenSource = cancellationTokenSource;

            _actionDispatcherSettings = actionDispatcherSettings;
        }
        public static IScheduleStrategies BuildSchedule(this ActionDispatcherSettings settings,
                                                        IQueueWorker queue,
                                                        ICounterBlocked processCount,
                                                        IWorkerHandler workerHandler)
        {
            var timeout = settings.Timeout == TimeSpan.MinValue ? TimeSpan.FromMinutes(1) : settings.Timeout;

            switch (settings.Schedule)
            {
            case ScheduleType.Parallel:
                return(new ScheduleParallel(queue, processCount, timeout, workerHandler));

            case ScheduleType.Sequenced:
                return(new ScheduleConsistent(queue, processCount, timeout, workerHandler));

            case ScheduleType.ParallelLimit:
                return(new ScheduleParallelLimit(queue, processCount, timeout, settings.PrefetchCount, workerHandler));
            }

            throw new ArgumentException("Schedule not found for " + settings.Schedule);
        }
示例#7
0
 public ScheduleConsistent(IQueueWorker queue, ICounterBlocked processCount, TimeSpan timeLimit, IWorkerHandler workerHandler)
     : base(queue, processCount, timeLimit, workerHandler)
 {
 }
 public DefaultWorkerChain(IQueueWorker queueWorker, ICounterBlocked counterBloaked)
 {
     _queueWorker         = queueWorker;
     _counterBlocked      = counterBloaked;
     _workerChainDefaults = new ConcurrentQueue <IActionInvoker>();
 }
 protected virtual IWorkerRunner CreateWorkerRunner(ICounterBlocked counterBlocked, IWorkerHandler workerHandler, TimeSpan timeLimit)
 {
     return(new DefaultWorkerRunner(_processCount, workerHandler, timeLimit, _queueWorker));
 }
示例#10
0
 public CounterBlockedStrong(ICounterBlocked counterBlocked)
 {
     _counterBlocked = counterBlocked;
 }