コード例 #1
0
        internal IndependentTimer GetTimer(DateTime time)
        {
            if (_timers.ContainsKey(time))
            {
                var cached = _timers[time].Target as IndependentTimer;
                if (cached != null)
                {
                    return(cached);
                }
            }
            if (2 * _purgePressure >= _timers.Count)
            {
                foreach (var key in _timers.Keys.ToList())
                {
                    if (!_timers[key].IsAlive)
                    {
                        _timers.Remove(key);
                    }
                }
                _purgePressure = 0;
            }
            var created = new IndependentTimer(this, time);

            _timers[time] = new WeakReference(created);
            ++_purgePressure;
            return(created);
        }
コード例 #2
0
        protected override int GetComponent(int component, TimeSpan cut, TimeSpan increment)
        {
            var next = Snapshot >= TimeSpan.Zero ? cut + increment : (-cut) + TimeSpan.FromTicks(1);

            IndependentTimer.Get(_zone, _zero + next).OnGet();
            IndependentTimer.Get(_zone, _zero + next - increment).OnGet();
            return(component);
        }
コード例 #3
0
 T GetComponent <T>(T component, DateTime prev, DateTime next)
 {
     IndependentTimer.Get(_zone, prev).OnGet();
     IndependentTimer.Get(_zone, next).OnGet();
     return(component);
 }
コード例 #4
0
 IndependentTimer GetTimer(DateTime comparand)
 {
     return(IndependentTimer.Get(_zone, comparand - _delta));
 }
コード例 #5
0
 internal void Dequeue(IndependentTimer timer)
 {
     _forth.Remove(timer);
     _back.Remove(timer);
 }
コード例 #6
0
 internal void Enqueue(IndependentTimer timer, bool expired)
 {
     (expired ? _back : _forth).Add(timer);
     ScheduleNext();
 }
コード例 #7
0
 IndependentTimer GetTimer(TimeSpan comparand)
 {
     return(IndependentTimer.Get(_zone, _zero + comparand));
 }
コード例 #8
0
 internal IndependentTimer GetTimer(DateTime time)
 {
     if (_timers.ContainsKey(time))
     {
         var cached = _timers[time].Target as IndependentTimer;
         if (cached != null)
             return cached;
     }
     if (2 * _purgePressure >= _timers.Count)
     {
         foreach (var key in _timers.Keys.ToList())
             if (!_timers[key].IsAlive)
                 _timers.Remove(key);
         _purgePressure = 0;
     }
     var created = new IndependentTimer(this, time);
     _timers[time] = new WeakReference(created);
     ++_purgePressure;
     return created;
 }
コード例 #9
0
 internal void Enqueue(IndependentTimer timer, bool expired)
 {
     (expired ? _back : _forth).Add(timer);
     ScheduleNext();
 }
コード例 #10
0
 internal void Dequeue(IndependentTimer timer)
 {
     _forth.Remove(timer);
     _back.Remove(timer);
 }