Пример #1
0
        //volatile bool _tracing = false;

        /// <summary>
        /// Constructor.
        /// </summary>
        public ArbiterSlim(Arbiter arbiter)
        {
            _arbiter    = arbiter;
            _threadPool = new ThreadPoolFastEx(arbiter.Name + ".Slim");
            arbiter.ClientAddedEvent   += new ClientManagerClientUpdateDelegate(arbiter_ClientAddedEvent);
            arbiter.ClientRemovedEvent += new ClientManagerClientUpdateDelegate(arbiter_ClientRemovedEvent);
        }
Пример #2
0
        public virtual void Dispose()
        {
            _isDisposed = true;

            ThreadPoolFastEx threadPool = _defaultThreadPool;

            if (threadPool != null)
            {
                threadPool.Dispose();
                _defaultThreadPool = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MessageBusBase(string name)
        {
            _name = name;

#if Matrix_Diagnostics
            _monitor = new InstanceMonitor(this);
#endif

            _defaultThreadPool = new ThreadPoolFastEx(name + ".DefaultThreadPool");

            _defaultThreadPool.MinimumThreadsCount = 5;
            _defaultThreadPool.MaximumThreadsCount = 10;
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        public ExecutionManager(Arbiter arbiter)
        {
            _arbiter    = arbiter;
            _threadPool = new ThreadPoolFastEx(typeof(ExecutionManager).Name);
            //_threadPool.MaximumSimultaniouslyRunningThreadsAllowed = 20;

            // Clear them promptly, since otherwise we seem to get stuck.
            _threadPool.ThreadIdle = TimeSpan.FromSeconds(1);

            _threadPool.MaximumThreadsCount = 25;

            _timeOutMonitor.EntityTimedOutEvent += new HandlerDelegate <TimeOutable>(_timeOutMonitor_EntityTimedOutEvent);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void UpdatePendingExecution()
        {
            ExecutionEntity entity;

            while (_pendingEntities != null &&
                   (entity = PopNextExecutionEntity()) != null)
            {
                TracerHelper.TraceEntry(" pending [" + _pendingEntities.Count + "] started executioners ["
                                        + _threadPool.ActiveRunningThreadsCount.ToString() + "]");

                ThreadPoolFastEx pool = _threadPool;
                if (pool != null)
                {
                    pool.Queue(new GeneralHelper.GenericDelegate <ExecutionEntity>(worker_DoWork), entity);
                }
            }
        }
Пример #6
0
        public void Dispose()
        {
            _isDisposed = true;

            ThreadPoolFastEx threadPool = _threadPool;

            if (threadPool != null)
            {
                threadPool.Dispose();
                _threadPool = null;
            }

            Arbiter arbiter = _arbiter;

            if (arbiter != null)
            {
                arbiter.ClientAddedEvent   -= new ClientManagerClientUpdateDelegate(arbiter_ClientAddedEvent);
                arbiter.ClientRemovedEvent -= new ClientManagerClientUpdateDelegate(arbiter_ClientRemovedEvent);
                _arbiter = null;
            }
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        public void Dispose()
        {
            ThreadPoolFastEx pool = _threadPool;

            if (pool != null)
            {
                pool.Dispose();
            }

            lock (this)
            {
                _pendingEntities.Clear();
                _pendingEntities = null;

                //_executionersAndClientIDs.Clear();
                _clientsRunningExecutioners.Clear();

                _timeOutMonitor.Dispose();
                _timeOutMonitor = null;
            }
        }