Replace Channel.Unsafe.setEventLoop() with register()
- Added AbstractChannel.doRegister()
This commit is contained in:
parent
a83b9704fa
commit
1356a0b61e
@ -349,17 +349,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
|
|
||||||
private class DefaultUnsafe implements Unsafe {
|
private class DefaultUnsafe implements Unsafe {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEventLoop(EventLoop eventLoop) {
|
|
||||||
if (eventLoop == null) {
|
|
||||||
throw new NullPointerException("eventLoop");
|
|
||||||
}
|
|
||||||
if (AbstractChannel.this.eventLoop != null) {
|
|
||||||
throw new IllegalStateException("attached to an event loop already");
|
|
||||||
}
|
|
||||||
AbstractChannel.this.eventLoop = eventLoop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public java.nio.channels.Channel ch() {
|
public java.nio.channels.Channel ch() {
|
||||||
return javaChannel();
|
return javaChannel();
|
||||||
@ -370,6 +359,20 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
return firstOut();
|
return firstOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(EventLoop eventLoop, ChannelFuture future) {
|
||||||
|
if (eventLoop == null) {
|
||||||
|
throw new NullPointerException("eventLoop");
|
||||||
|
}
|
||||||
|
if (AbstractChannel.this.eventLoop != null) {
|
||||||
|
throw new IllegalStateException("registered to an event loop already");
|
||||||
|
}
|
||||||
|
AbstractChannel.this.eventLoop = eventLoop;
|
||||||
|
|
||||||
|
assert eventLoop().inEventLoop();
|
||||||
|
doRegister(future);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bind(final SocketAddress localAddress, final ChannelFuture future) {
|
public void bind(final SocketAddress localAddress, final ChannelFuture future) {
|
||||||
if (eventLoop().inEventLoop()) {
|
if (eventLoop().inEventLoop()) {
|
||||||
@ -465,6 +468,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
protected abstract java.nio.channels.Channel javaChannel();
|
protected abstract java.nio.channels.Channel javaChannel();
|
||||||
protected abstract ChannelBufferHolder<Object> firstOut();
|
protected abstract ChannelBufferHolder<Object> firstOut();
|
||||||
|
|
||||||
|
protected abstract void doRegister(ChannelFuture future);
|
||||||
protected abstract void doBind(SocketAddress localAddress, ChannelFuture future);
|
protected abstract void doBind(SocketAddress localAddress, ChannelFuture future);
|
||||||
protected abstract void doConnect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future);
|
protected abstract void doConnect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future);
|
||||||
protected abstract void doDisconnect(ChannelFuture future);
|
protected abstract void doDisconnect(ChannelFuture future);
|
||||||
|
@ -181,10 +181,10 @@ public interface Channel extends AttributeMap, ChannelFutureFactory, Comparable<
|
|||||||
Unsafe unsafe();
|
Unsafe unsafe();
|
||||||
|
|
||||||
public interface Unsafe {
|
public interface Unsafe {
|
||||||
void setEventLoop(EventLoop eventLoop);
|
|
||||||
java.nio.channels.Channel ch();
|
java.nio.channels.Channel ch();
|
||||||
ChannelBufferHolder<Object> out();
|
ChannelBufferHolder<Object> out();
|
||||||
|
|
||||||
|
void register(EventLoop eventLoop, ChannelFuture future);
|
||||||
void bind(SocketAddress localAddress, ChannelFuture future);
|
void bind(SocketAddress localAddress, ChannelFuture future);
|
||||||
void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future);
|
void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future);
|
||||||
void disconnect(ChannelFuture future);
|
void disconnect(ChannelFuture future);
|
||||||
|
Loading…
Reference in New Issue
Block a user