Example #1
0
    /**
     * Processes events in the event queue of the Poller.
     *
     * @return <code>true</code> if some events were processed, <code>false</code> if queue was
     *     empty
     */
    public boolean events() {
      boolean result = false;

      PollerEvent pe = null;
      while ((pe = events.poll()) != null) {
        result = true;
        try {
          pe.run();
          pe.reset();
          if (running && !paused) {
            eventCache.push(pe);
          }
        } catch (Throwable x) {
          log.error("", x);
        }
      }

      return result;
    }
Example #2
0
 private void addEvent(PollerEvent event) {
   events.offer(event);
   if (wakeupCounter.incrementAndGet() == 0) selector.wakeup();
 }