package org.glassfish.grizzly.nio;
import java.io.IOException;
import java.nio.channels.SelectableChannel;
import org.glassfish.grizzly.GrizzlyFuture;
import org.glassfish.grizzly.impl.FutureImpl;
import org.glassfish.grizzly.utils.Futures;
public abstract class AbstractNIOConnectionDistributor implements NIOChannelDistributor {
protected final NIOTransport transport;
public AbstractNIOConnectionDistributor(final NIOTransport transport) {
this.transport = transport;
}
@Override
public final void registerChannel(final SelectableChannel channel) throws IOException {
registerChannel(channel, 0, null);
}
@Override
public final void registerChannel(final SelectableChannel channel, final int interestOps) throws IOException {
registerChannel(channel, interestOps, null);
}
@Override
public final GrizzlyFuture<RegisterChannelResult> registerChannelAsync(final SelectableChannel channel) {
return registerChannelAsync(channel, 0, null);
}
@Override
public final GrizzlyFuture<RegisterChannelResult> registerChannelAsync(final SelectableChannel channel, final int interestOps) {
return registerChannelAsync(channel, interestOps, null);
}
@Override
public final GrizzlyFuture<RegisterChannelResult> registerChannelAsync(final SelectableChannel channel, final int interestOps, final Object attachment) {
final FutureImpl<RegisterChannelResult> future = Futures.createSafeFuture();
registerChannelAsync(channel, interestOps, attachment, Futures.toCompletionHandler(future));
return future;
}
protected SelectorRunner[] getTransportSelectorRunners() {
return transport.getSelectorRunners();
}
}