Esempio n. 1
0
  void onTimeout(int hand) {
    final ReentrantLock lock = m_lock;
    // If the lock cannot be acquired, which means this notifier is being
    // cancelled or rescheduled or closed, just skip.
    if (!lock.tryLock()) return;

    try {
      // If this notifier is not in the same timeout sublist,
      // which means it has been cancelled or rescheduled,
      // then skip.
      TimeoutEvent event = m_node.get();
      if (event == null || hand != event.getIndex()) return;

      if (event.getTimeLeft() < 1) {
        changeState(TimedOut.getInstance());
        m_admin.fireTimeout(this);
      } else m_admin.scheduleNextRound(this);
    } finally {
      lock.unlock();
    }
  }
Esempio n. 2
0
 @Override
 public boolean schedule(TimeoutNotifier notifier, int timeout) {
   notifier.getTimeoutAdmin().schedule(notifier, timeout);
   notifier.changeState(Scheduled.getInstance());
   return true;
 }
Esempio n. 3
0
 @Override
 public void close(TimeoutNotifier notifier) {
   notifier.getTimeoutAdmin().cancel(notifier);
   notifier.changeState(Closed.getInstance());
 }
Esempio n. 4
0
 @Override
 public boolean cancel(TimeoutNotifier notifier) {
   notifier.getTimeoutAdmin().cancel(notifier);
   notifier.changeState(Unscheduled.getInstance());
   return true;
 }
Esempio n. 5
0
 @Override
 public void close(TimeoutNotifier notifier) {
   notifier.changeState(Closed.getInstance());
 }
Esempio n. 6
0
 @Override
 public boolean reset(TimeoutNotifier notifier) {
   notifier.changeState(Unscheduled.getInstance());
   return true;
 }