
org.simpleframework.util.select.Event Maven / Gradle / Ivy
/*
* Event.java February 2007
*
* Copyright (C) 2007, Niall Gallagher
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
package org.simpleframework.util.select;
import java.nio.channels.SelectableChannel;
/**
* The Event
object is used to represent an event that
* the distributor is to process. This contains the operation and
* the required I/O events as an integer bit mask. When an operation
* is considered ready it will be handed to an executor to execute.
*
* @author Niall Gallagher
*/
interface Event extends Runnable {
/**
* This is used to get the expiry for the operation. The expiry
* represents some static time in the future when the event will
* expire if it does not become ready. This is used to cancel the
* operation so that it does not remain in the distributor.
*
* @return the remaining time this operation will wait for
*/
public long getExpiry();
/**
* This returns the I/O operations that the event is interested
* in as an integer bit mask. When any of these operations are
* ready the distributor will execute the provided operation.
*
* @return the integer bit mask of interested I/O operations
*/
public int getInterest();
/**
* This is the SelectableChannel
which is used to
* determine if the operation should be executed. If the channel
* is ready for a given I/O event it can be run. For instance if
* the operation is used to perform some form of read operation
* it can be executed when ready to read data from the channel.
*
* @return this returns the channel used to govern execution
*/
public SelectableChannel getChannel();
/**
* This is used to acquire the Operation
that is to
* be executed when the required operations are ready. It is the
* responsibility of the distributor to invoke the operation.
*
* @return the operation to be executed when it is ready
*/
public Operation getOperation();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy