コード例 #1
0
 private void async_timed_wait_(long id, int ms, go_mutex mutex, Action <bool> ntf)
 {
     if (ms >= 0)
     {
         async_timer timer = new async_timer(_strand);
         LinkedListNode <tuple <long, go_mutex, Action> > node = _waitQueue.AddLast(new tuple <long, go_mutex, Action>(id, mutex, delegate()
         {
             timer.cancel();
             mutex.async_lock(id, () => ntf(true));
         }));
         timer.timeout(ms, delegate()
         {
             _waitQueue.Remove(node);
             mutex.async_lock(id, () => ntf(false));
         });
     }
     else
     {
         _waitQueue.AddLast(new tuple <long, go_mutex, Action>(id, mutex, () => mutex.async_lock(id, () => ntf(true))));
     }
 }
コード例 #2
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))));
         }
     });
 }