示例#1
0
        public static TaskThrottler Get(string name, int?concurrentItems = null)
        {
            _lock.EnterUpgradeableReadLock();

            try
            {
                if (Throttles.ContainsKey(name))
                {
                    return(Throttles[name]);
                }

                _lock.EnterWriteLock();

                try
                {
                    var newThrottle = new TaskThrottler(name, concurrentItems ?? 10);

                    Throttles.Add(name, newThrottle);

                    Debug.WriteLine("Added name");

                    return(newThrottle);
                }
                finally
                {
                    _lock.ExitWriteLock();
                }
            }
            finally
            {
                _lock.ExitUpgradeableReadLock();
            }
        }
示例#2
0
 internal Releaser(TaskThrottler toRelease)
 {
     m_toRelease = toRelease;
 }