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
|
|
|
|
2012-05-01 11:31:17 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
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
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
public abstract class CompleteChannelFuture implements ChannelFuture {
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
protected CompleteChannelFuture(Channel channel) {
|
|
|
|
if (channel == null) {
|
|
|
|
throw new NullPointerException("channel");
|
|
|
|
}
|
|
|
|
this.channel = channel;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-14 16:57:23 +02:00
|
|
|
public ChannelFuture addListener(final ChannelFutureListener listener) {
|
2012-05-28 14:05:49 +02:00
|
|
|
if (listener == null) {
|
|
|
|
throw new NullPointerException("listener");
|
2012-05-01 11:31:17 +02:00
|
|
|
}
|
2012-05-28 14:05:49 +02:00
|
|
|
DefaultChannelFuture.notifyListener(this, listener);
|
2012-05-14 16:57:23 +02:00
|
|
|
return this;
|
2012-05-01 11:31:17 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-14 16:57:23 +02:00
|
|
|
public ChannelFuture removeListener(ChannelFutureListener listener) {
|
2008-08-08 02:37:18 +02:00
|
|
|
// NOOP
|
2012-05-14 16:57:23 +02:00
|
|
|
return this;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public ChannelFuture await() throws InterruptedException {
|
2009-09-04 06:21:56 +02:00
|
|
|
if (Thread.interrupted()) {
|
|
|
|
throw new InterruptedException();
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
|
2009-09-04 06:21:56 +02:00
|
|
|
if (Thread.interrupted()) {
|
|
|
|
throw new InterruptedException();
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean await(long timeoutMillis) throws InterruptedException {
|
2009-09-04 06:21:56 +02:00
|
|
|
if (Thread.interrupted()) {
|
|
|
|
throw new InterruptedException();
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public ChannelFuture awaitUninterruptibly() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean awaitUninterruptibly(long timeoutMillis) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean isDone() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2010-02-19 10:58:38 +01:00
|
|
|
public boolean setProgress(long amount, long current, long total) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-11-26 10:21:00 +01:00
|
|
|
public boolean setFailure(Throwable cause) {
|
|
|
|
return false;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-11-26 10:21:00 +01:00
|
|
|
public boolean setSuccess() {
|
|
|
|
return false;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean cancel() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2008-08-08 02:37:18 +02:00
|
|
|
public boolean isCancelled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|