The state value of channelInterestChanged event is useless - added the event triggering method which doesn't require a state value and deprecated the old ones

This commit is contained in:
Trustin Lee 2009-01-08 00:26:41 +00:00
parent bd403bdb98
commit 7a9c72fd76
5 changed files with 46 additions and 34 deletions

View File

@ -329,32 +329,58 @@ public class Channels {
* Sends a {@code "channelInterestChanged"} event to the first
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
* the specified {@link Channel}.
*
* @param interestOps the new interestOps
*/
public static void fireChannelInterestChanged(Channel channel, int interestOps) {
validateInterestOps(interestOps);
public static void fireChannelInterestChanged(Channel channel) {
channel.getPipeline().sendUpstream(
new DefaultChannelStateEvent(
channel, succeededFuture(channel),
ChannelState.INTEREST_OPS, Integer.valueOf(interestOps)));
ChannelState.INTEREST_OPS, Channel.OP_READ));
}
/**
* @deprecated Use {@link #fireChannelInterestChanged(Channel)} instead.
*
* Sends a {@code "channelInterestChanged"} event to the first
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
* the specified {@link Channel}.
*
* @param interestOps the new interestOps
*/
@Deprecated
public static void fireChannelInterestChanged(
Channel channel, @SuppressWarnings("unused") int interestOps) {
fireChannelInterestChanged(channel);
}
/**
* Sends a {@code "channelInterestChanged"} event to the next
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
* the specified {@link ChannelHandlerContext} belongs.
*
* @param interestOps the new interestOps
*/
public static void fireChannelInterestChanged(
ChannelHandlerContext ctx, Channel channel, int interestOps) {
ChannelHandlerContext ctx, Channel channel) {
validateInterestOps(interestOps);
ctx.sendUpstream(
new DefaultChannelStateEvent(
channel, succeededFuture(channel),
ChannelState.INTEREST_OPS, Integer.valueOf(interestOps)));
ChannelState.INTEREST_OPS, Channel.OP_READ));
}
/**
* @deprecated Use {@link #fireChannelInterestChanged(ChannelHandlerContext, Channel)} instead.
*
* Sends a {@code "channelInterestChanged"} event to the next
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
* the specified {@link ChannelHandlerContext} belongs.
*
* @param interestOps the new interestOps
*/
@Deprecated
public static void fireChannelInterestChanged(
ChannelHandlerContext ctx, Channel channel,
@SuppressWarnings("unused") int interestOps) {
fireChannelInterestChanged(ctx, channel);
}
/**

View File

@ -89,24 +89,12 @@ public class DefaultChannelStateEvent extends DefaultChannelEvent implements
}
break;
case INTEREST_OPS:
switch (((Integer) getValue()).intValue()) {
case Channel.OP_NONE:
buf.append("OP_NONE");
break;
case Channel.OP_READ:
buf.append("OP_READ");
break;
case Channel.OP_WRITE:
buf.append("OP_WRITE");
break;
case Channel.OP_READ_WRITE:
buf.append("OP_READ_WRITE");
break;
default:
buf.append("UNKNOWN(");
buf.append(getValue());
buf.append(')');
}
buf.append("INTEREST_CHANGED");
break;
default:
buf.append(getState().name());
buf.append(": ");
buf.append(getValue());
}
buf.append(')');
return buf.toString();

View File

@ -185,8 +185,7 @@ abstract class NioSocketChannel extends AbstractChannel
highWaterMarkCounter.incrementAndGet();
if (!notifying.get()) {
notifying.set(Boolean.TRUE);
fireChannelInterestChanged(
NioSocketChannel.this, getRawInterestOps() | OP_WRITE);
fireChannelInterestChanged(NioSocketChannel.this);
notifying.set(Boolean.FALSE);
}
}
@ -207,8 +206,7 @@ abstract class NioSocketChannel extends AbstractChannel
highWaterMarkCounter.decrementAndGet();
if (!notifying.get()) {
notifying.set(Boolean.TRUE);
fireChannelInterestChanged(
NioSocketChannel.this, getRawInterestOps() & ~OP_WRITE);
fireChannelInterestChanged(NioSocketChannel.this);
notifying.set(Boolean.FALSE);
}
}

View File

@ -686,7 +686,7 @@ class NioWorker implements Runnable {
future.setSuccess();
if (changed) {
channel.setRawInterestOpsNow(interestOps);
fireChannelInterestChanged(channel, interestOps);
fireChannelInterestChanged(channel);
}
} catch (Throwable t) {
future.setFailure(t);

View File

@ -151,7 +151,7 @@ class OioWorker implements Runnable {
}
channel.setInterestOpsNow(interestOps);
fireChannelInterestChanged(channel, interestOps);
fireChannelInterestChanged(channel);
}
} catch (Throwable t) {
future.setFailure(t);