2008-08-08 02:37:18 +02:00
|
|
|
/*
|
2012-06-04 22:31:44 +02:00
|
|
|
* Copyright 2012 The Netty Project
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2012-06-04 22:31:44 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-08-08 03:27:24 +02:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
2011-12-09 06:18:34 +01:00
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
2009-08-28 09:15:49 +02:00
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.channel;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2013-03-05 21:41:19 +01:00
|
|
|
import io.netty.util.concurrent.CompleteFuture;
|
|
|
|
import io.netty.util.concurrent.EventExecutor;
|
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
2012-05-01 11:31:17 +02:00
|
|
|
|
2008-08-11 09:33:19 +02:00
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* A skeletal {@link ChannelFuture} implementation which represents a
|
|
|
|
* {@link ChannelFuture} which has been completed already.
|
2008-08-11 09:33:19 +02:00
|
|
|
*/
|
2013-03-18 14:18:31 +01:00
|
|
|
abstract class CompleteChannelFuture extends CompleteFuture<Void> implements ChannelFuture {
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
private final Channel channel;
|
|
|
|
|
2008-08-11 09:33:19 +02:00
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
|
|
|
*
|
|
|
|
* @param channel the {@link Channel} associated with this future
|
|
|
|
*/
|
2013-03-05 21:41:19 +01:00
|
|
|
protected CompleteChannelFuture(Channel channel, EventExecutor executor) {
|
|
|
|
super(executor);
|
2008-08-08 02:37:18 +02:00
|
|
|
if (channel == null) {
|
|
|
|
throw new NullPointerException("channel");
|
|
|
|
}
|
|
|
|
this.channel = channel;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-03-05 21:41:19 +01:00
|
|
|
protected EventExecutor executor() {
|
|
|
|
EventExecutor e = super.executor();
|
|
|
|
if (e == null) {
|
|
|
|
return channel().eventLoop();
|
|
|
|
} else {
|
|
|
|
return e;
|
2012-05-01 11:31:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-14 04:45:43 +01:00
|
|
|
@Override
|
2013-06-12 01:00:54 +02:00
|
|
|
public ChannelFuture addListener(GenericFutureListener<? extends Future<? super Void>> listener) {
|
2013-03-05 21:41:19 +01:00
|
|
|
super.addListener(listener);
|
2012-12-14 04:45:43 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-06-12 01:00:54 +02:00
|
|
|
public ChannelFuture addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
|
2013-03-05 21:41:19 +01:00
|
|
|
super.addListeners(listeners);
|
2012-05-14 16:57:23 +02:00
|
|
|
return this;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2012-12-14 04:45:43 +01:00
|
|
|
@Override
|
2013-06-12 01:00:54 +02:00
|
|
|
public ChannelFuture removeListener(GenericFutureListener<? extends Future<? super Void>> listener) {
|
2013-03-05 21:41:19 +01:00
|
|
|
super.removeListener(listener);
|
2012-12-14 04:45:43 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-06-12 01:00:54 +02:00
|
|
|
public ChannelFuture removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
|
2013-03-05 21:41:19 +01:00
|
|
|
super.removeListeners(listeners);
|
2008-08-08 02:37:18 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-03-05 21:41:19 +01:00
|
|
|
public ChannelFuture syncUninterruptibly() {
|
|
|
|
return this;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-03-05 21:41:19 +01:00
|
|
|
public ChannelFuture sync() throws InterruptedException {
|
2008-08-08 02:37:18 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-03-05 21:41:19 +01:00
|
|
|
public ChannelFuture await() throws InterruptedException {
|
|
|
|
return this;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-03-05 21:41:19 +01:00
|
|
|
public ChannelFuture awaitUninterruptibly() {
|
|
|
|
return this;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
public Channel channel() {
|
2008-08-08 02:37:18 +02:00
|
|
|
return channel;
|
|
|
|
}
|
2013-03-18 14:18:31 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Void getNow() {
|
|
|
|
return null;
|
|
|
|
}
|
2014-07-02 10:39:34 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isVoid() {
|
|
|
|
return false;
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|