Пример #1
0
        public WorkersCoordinator(string name, int maxWorkersCount,
                                  IMessageReaderFactory messageReaderFactory,
                                  IRebusLoggerFactory rebusLoggerFactory,
                                  int maxReadParallelism   = 4,
                                  bool asyncReadThrottling = false,
                                  TimeSpan?shutdownTimeout = null
                                  )
        {
            this.Log = rebusLoggerFactory.GetLogger <WorkersCoordinator>();
            // the current PrimaryReader does not use BottleNeck hence: maxReadParallelism - 1
            int throttleCount = Math.Max(maxReadParallelism - 1, 1);

            this._name                = name;
            this._stoppingTask        = null;
            this._tasksCanBeStarted   = 0;
            this._stopTokenSource     = null;
            this._cancellationToken   = CancellationToken.None;
            this._readerFactory       = messageReaderFactory;
            this._maxWorkersCount     = maxWorkersCount;
            this._taskIdSeq           = 0;
            this._tasks               = new ConcurrentDictionary <long, Task>();
            this._isStarted           = 0;
            this._asyncReadThrottling = asyncReadThrottling;
            this._readThrottling      = new Bottleneck(throttleCount);
            this._shutdownTimeout     = shutdownTimeout ?? TimeSpan.FromMilliseconds(STOP_TIMEOUT_MSec);
        }
Пример #2
0
        public BaseTasksCoordinator(ILoggerFactory loggerFactory, IMessageReaderFactory messageReaderFactory,
                                    int maxTasksCount, bool isQueueActivationEnabled = false, int maxReadParallelism = 4)
        {
            this.Logger = loggerFactory.CreateLogger(this.GetType().Name);
            // the current PrimaryReader does not use BottleNeck hence: maxReadParallelism - 1
            int throttleCount = Math.Max(maxReadParallelism - 1, 1);

            this._tasksCanBeStarted       = 0;
            this._stopTokenSource         = null;
            this._cancellationToken       = CancellationToken.None;
            this._readerFactory           = messageReaderFactory;
            this._maxTasksCount           = maxTasksCount;
            this.IsQueueActivationEnabled = isQueueActivationEnabled;
            this._taskIdSeq      = 0;
            this._tasks          = new ConcurrentDictionary <long, Task>();
            this._isStarted      = 0;
            this._readBottleNeck = new Bottleneck(throttleCount);
        }
Пример #3
0
 public SSSBTasksCoordinator(ILoggerFactory loggerFactory, IMessageReaderFactory messageReaderFactory,
                             int maxReadersCount, bool isQueueActivationEnabled = false, int maxReadParallelism = 4) :
     base(loggerFactory, messageReaderFactory, maxReadersCount, isQueueActivationEnabled, maxReadParallelism)
 {
 }