Exemplo n.º 1
0
        internal ObservableTimer GetTimer(DateTime time)
        {
            if (_timers.ContainsKey(time))
            {
                var cached = _timers[time].Target as ObservableTimer;
                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 ObservableTimer(this, time);

            _timers[time] = new WeakReference(created);
            ++_purgePressure;
            return(created);
        }
Exemplo n.º 2
0
        protected override int GetComponent(int component, TimeSpan cut, TimeSpan increment)
        {
            var next = Snapshot <= TimeSpan.Zero ? (-cut) - increment : cut - TimeSpan.FromTicks(1);

            ObservableTimer.Get(_zone, _zero - next).OnGet();
            ObservableTimer.Get(_zone, _zero - next - increment).OnGet();
            return(component);
        }
Exemplo n.º 3
0
 T GetComponent <T>(T component, DateTime prev, DateTime next)
 {
     ObservableTimer.Get(_zone, prev).OnGet();
     ObservableTimer.Get(_zone, next).OnGet();
     return(component);
 }
Exemplo n.º 4
0
 ObservableTimer GetTimer(DateTime comparand)
 {
     return(ObservableTimer.Get(_zone, comparand - _delta));
 }
Exemplo n.º 5
0
 ObservableTimer GetTimer(TimeSpan comparand)
 {
     return(ObservableTimer.Get(_zone, _zero - comparand));
 }
Exemplo n.º 6
0
 internal void Dequeue(ObservableTimer timer)
 {
     _forth.Remove(timer);
     _back.Remove(timer);
 }
Exemplo n.º 7
0
 internal void Enqueue(ObservableTimer timer, bool expired)
 {
     (expired ? _back : _forth).Add(timer);
     ScheduleNext();
 }
Exemplo n.º 8
0
 internal ObservableTimer GetTimer(DateTime time)
 {
     if (_timers.ContainsKey(time))
     {
         var cached = _timers[time].Target as ObservableTimer;
         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 ObservableTimer(this, time);
     _timers[time] = new WeakReference(created);
     ++_purgePressure;
     return created;
 }
Exemplo n.º 9
0
 internal void Enqueue(ObservableTimer timer, bool expired)
 {
     (expired ? _back : _forth).Add(timer);
     ScheduleNext();
 }
Exemplo n.º 10
0
 internal void Dequeue(ObservableTimer timer)
 {
     _forth.Remove(timer);
     _back.Remove(timer);
 }