private void scheduleFlush(S session) {
   // add the session to the queue if it's not already
   // in the queue
   if (session.setScheduledForFlush(true)) {
     flushingSessions.add(session);
   }
 }
 /** {@inheritDoc} */
 public final void flush(S session) {
   // add the session to the queue if it's not already
   // in the queue, then wake up the select()
   if (session.setScheduledForFlush(true)) {
     flushingSessions.add(session);
     wakeup();
   }
 }
  /** Deal with session ready for the read or write operations, or both. */
  private void process(S session) {
    // Process Reads
    if (isReadable(session) && !session.isReadSuspended()) {
      read(session);
    }

    // Process writes
    if (isWritable(session) && !session.isWriteSuspended()) {
      // add the session to the queue, if it's not already there
      if (session.setScheduledForFlush(true)) {
        flushingSessions.add(session);
      }
    }
  }