2012-06-04 13:31:44 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2012 The Netty Project
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2012-05-09 22:09:06 +09:00
|
|
|
package io.netty.channel;
|
|
|
|
|
2012-08-18 22:53:58 +09:00
|
|
|
import java.util.concurrent.ExecutionException;
|
2012-05-09 22:09:06 +09:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2012-08-18 22:53:58 +09:00
|
|
|
import java.util.concurrent.TimeoutException;
|
2012-05-09 22:09:06 +09:00
|
|
|
|
2012-05-13 01:35:43 +09:00
|
|
|
public class VoidChannelFuture implements ChannelFuture.Unsafe {
|
2012-05-09 22:09:06 +09:00
|
|
|
|
|
|
|
private final Channel channel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
|
|
|
*
|
|
|
|
* @param channel the {@link Channel} associated with this future
|
|
|
|
*/
|
|
|
|
public VoidChannelFuture(Channel channel) {
|
|
|
|
if (channel == null) {
|
|
|
|
throw new NullPointerException("channel");
|
|
|
|
}
|
|
|
|
this.channel = channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-14 23:57:23 +09:00
|
|
|
public ChannelFuture addListener(final ChannelFutureListener listener) {
|
2012-05-09 22:09:06 +09:00
|
|
|
fail();
|
2012-05-14 23:57:23 +09:00
|
|
|
return this;
|
2012-05-09 22:09:06 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-14 23:57:23 +09:00
|
|
|
public ChannelFuture removeListener(ChannelFutureListener listener) {
|
2012-05-09 22:09:06 +09:00
|
|
|
// NOOP
|
2012-05-14 23:57:23 +09:00
|
|
|
return this;
|
2012-05-09 22:09:06 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture await() throws InterruptedException {
|
|
|
|
if (Thread.interrupted()) {
|
|
|
|
throw new InterruptedException();
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
|
|
|
|
fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean await(long timeoutMillis) throws InterruptedException {
|
|
|
|
fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture awaitUninterruptibly() {
|
|
|
|
fail();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
|
|
|
|
fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean awaitUninterruptibly(long timeoutMillis) {
|
|
|
|
fail();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Channel channel() {
|
|
|
|
return channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isDone() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isCancelled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSuccess() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Throwable cause() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-14 23:57:23 +09:00
|
|
|
public ChannelFuture sync() throws InterruptedException {
|
|
|
|
fail();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture syncUninterruptibly() {
|
2012-05-09 22:09:06 +09:00
|
|
|
fail();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-08-18 22:53:58 +09:00
|
|
|
@Override
|
|
|
|
public Void get() throws InterruptedException, ExecutionException {
|
|
|
|
fail();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
|
|
|
|
TimeoutException {
|
|
|
|
fail();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-05-09 22:09:06 +09:00
|
|
|
@Override
|
|
|
|
public boolean setProgress(long amount, long current, long total) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean setFailure(Throwable cause) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean setSuccess() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean cancel() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-18 22:53:58 +09:00
|
|
|
@Override
|
|
|
|
public boolean cancel(boolean mayInterruptIfRunning) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-09 22:09:06 +09:00
|
|
|
private static void fail() {
|
|
|
|
throw new IllegalStateException("void future");
|
|
|
|
}
|
|
|
|
}
|