Exemple #1
0
        public void timeout(int ms, functional.func handler)
        {
#if DEBUG
            Trace.Assert(_strand.running_in_this_thread() && null == _timer && null != handler);
#endif
            _isInterval  = false;
            _handler     = handler;
            _lastTimeout = ms;
            _timerCount++;
            _beginTick = system_tick.get_tick_ms();
            begin_timer(_beginTick, ms, 0);
        }
Exemple #2
0
 internal void async_lock(long id, Action ntf)
 {
     if (_strand.running_in_this_thread())
     {
         if (!_mustTick)
         {
             async_lock_(id, ntf);
         }
         else
         {
             _strand.add_last(() => async_lock_(id, ntf));
         }
     }
     else
     {
         _strand.post(() => async_lock_(id, ntf));
     }
 }
Exemple #3
0
 internal void async_wait(long id, go_mutex mutex, Action ntf)
 {
     mutex.async_unlock(id, delegate()
     {
         if (_strand.running_in_this_thread())
         {
             if (!_mustTick)
             {
                 _waitQueue.AddLast(new tuple <long, go_mutex, Action>(id, mutex, () => mutex.async_lock(id, ntf)));
             }
             else
             {
                 _strand.add_last(() => _waitQueue.AddLast(new tuple <long, go_mutex, Action>(id, mutex, () => mutex.async_lock(id, ntf))));
             }
         }
         else
         {
             _strand.post(() => _waitQueue.AddLast(new tuple <long, go_mutex, Action>(id, mutex, () => mutex.async_lock(id, ntf))));
         }
     });
 }
Exemple #4
0
        public long timeout_us(long us, Action handler)
        {
            Debug.Assert(_strand.running_in_this_thread() && null == _handler && null != handler, "不正确的 timeout_us 调用!");
            _isInterval = false;
            _handler    = handler;
            _strand.hold_work();
            long nowus = _utcMode ? utc_tick.get_tick_us() : system_tick.get_tick_us();

            begin_timer(nowus, us > 0 ? nowus + us : nowus, us > 0 ? us : 0);
            return(nowus);
        }
Exemple #5
0
 public long timeout_us(long us, Action handler)
 {
     Debug.Assert(_strand.running_in_this_thread() && null == _handler && null != handler, "不正确的 timeout_us 调用!");
     _isInterval = false;
     _handler    = handler;
     _strand.hold_work();
     _beginTick = _utcMode ? utc_tick.get_tick_us() : system_tick.get_tick_us();
     if (0 < us)
     {
         begin_timer(_beginTick + us, us);
     }
     else
     {
         tick_timer(_beginTick);
     }
     return(_beginTick);
 }