Esempio n. 1
0
 private void async_cancel_(long id, Action ntf)
 {
     for (LinkedListNode <tuple <long, go_mutex, Action> > it = _waitQueue.First; null != it; it = it.Next)
     {
         if (id == it.Value.value1)
         {
             go_mutex mtx = it.Value.value2;
             mtx.async_cancel(id, ntf);
             return;
         }
     }
     ntf();
 }
Esempio n. 2
0
 internal void async_timed_wait(long id, int ms, go_mutex mutex, Action <bool> ntf)
 {
     mutex.async_unlock(id, delegate()
     {
         if (_strand.running_in_this_thread())
         {
             if (!_mustTick)
             {
                 async_timed_wait_(id, ms, mutex, ntf);
             }
             else
             {
                 _strand.add_last(() => async_timed_wait_(id, ms, mutex, ntf));
             }
         }
         else
         {
             _strand.post(() => async_timed_wait_(id, ms, mutex, ntf));
         }
     });
 }
Esempio n. 3
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))));
     }
 }
Esempio n. 4
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))));
         }
     });
 }
Esempio n. 5
0
 public ValueTask <bool> timed_wait(go_mutex mutex, int ms)
 {
     return(generator.condition_timed_wait(this, mutex, ms));
 }
Esempio n. 6
0
 public Task timed_wait(async_result_wrap <bool> res, go_mutex mutex, int ms)
 {
     return(generator.condition_timed_wait(res, this, mutex, ms));
 }
Esempio n. 7
0
 public Task wait(go_mutex mutex)
 {
     return(generator.condition_wait(this, mutex));
 }