Ejemplo n.º 1
0
        public void RecycleMembers()
        {
            List <TMember> wouldBeRemovedMembers = new List <TMember>();

            foreach (var item in _mapping)
            {
                if (!item.Value.IsRunning && item.Value.Length <= 0)
                {
                    wouldBeRemovedMembers.Add(item.Key);
                }
            }

            lock (_syncRoot)
            {
                foreach (var member in wouldBeRemovedMembers)
                {
                    SmartQueue <TItem> queue = _mapping[member];
                    if (!queue.IsRunning && queue.Length <= 0)
                    {
                        _mapping.Remove(member);
                        queue.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void Remove(TMember member)
 {
     lock (_syncRoot)
     {
         if (_mapping.ContainsKey(member))
         {
             SmartQueue <TItem> queue = _mapping[member];
             _mapping.Remove(member);
             queue.Dispose();
         }
     }
 }
Ejemplo n.º 3
0
        public void Enqueue(TMember member, TItem item)
        {
            lock (_syncRoot)
            {
                if (!_mapping.ContainsKey(member))
                {
                    string queueName = string.Format(CultureInfo.InvariantCulture, "{0}#{1}", Name, member.ToString());
                    var    queue     = new SmartQueue <TItem>(queueName, _action, true)
                    {
                        IsActionAsyncMode = false
                    };
                    _mapping.Add(member, queue); // default queue reclaimed
                    if (IsHoldup)
                    {
                        queue.Pause();
                    }
                }

                _mapping[member].Enqueue(item);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 计划任务管理器
 /// </summary>
 private ScheduleTaskManager()
 {
     _queue = new SmartQueue <IScheduleTask>("ScheduleTaskManager", PreSchedule, true, 25);
 }