Remove ChannelFutureProgressListener

This commit is contained in:
Norman Maurer 2012-12-31 14:42:33 +01:00 committed by Trustin Lee
parent 4e77bacdf7
commit e0a6dc0ac3
7 changed files with 0 additions and 189 deletions

View File

@ -1052,15 +1052,5 @@ public class SslHandler
public void setFailure(Throwable cause) {
throw new IllegalStateException();
}
@Override
public void setProgress(long amount, long current, long total) {
throw new IllegalStateException();
}
@Override
public boolean tryProgress(long amount, long current, long total) {
return false;
}
}
}

View File

@ -1018,16 +1018,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
throw new IllegalStateException();
}
@Override
public void setProgress(long amount, long current, long total) {
throw new IllegalStateException();
}
@Override
public boolean tryProgress(long amount, long current, long total) {
throw new IllegalStateException();
}
@Override
public boolean trySuccess() {
throw new IllegalStateException();

View File

@ -1,49 +0,0 @@
/*
* 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.
*/
package io.netty.channel;
/**
* Listens to the progress of a time-consuming I/O operation such as a large
* file transfer. If this listener is added to a {@link ChannelFuture} of an
* I/O operation that supports progress notification, the listener's
* {@link #operationProgressed(ChannelFuture, long, long, long)} method will be
* called back by an I/O thread. If the operation does not support progress
* notification, {@link #operationProgressed(ChannelFuture, long, long, long)}
* will not be invoked. Like a usual {@link ChannelFutureListener} that this
* interface extends, {@link #operationComplete(ChannelFuture)} will be called
* when the future is marked as complete.
*
* <h3>Return the control to the caller quickly</h3>
*
* {@link #operationProgressed(ChannelFuture, long, long, long)} and
* {@link #operationComplete(ChannelFuture)} is directly called by an I/O
* thread. Therefore, performing a time consuming task or a blocking operation
* in the handler method can cause an unexpected pause during I/O. If you need
* to perform a blocking operation on I/O completion, try to execute the
* operation in a different thread using a thread pool.
*/
public interface ChannelFutureProgressListener extends ChannelFutureListener {
/**
* Invoked when the I/O operation associated with the {@link ChannelFuture}
* has been progressed.
*
* @param future the source {@link ChannelFuture} which called this
* callback
*/
void operationProgressed(ChannelFuture future, long amount, long current, long total) throws Exception;
}

View File

@ -56,26 +56,6 @@ public interface ChannelPromise extends ChannelFuture {
*/
boolean tryFailure(Throwable cause);
/**
* Notifies the progress of the operation to the listeners that implements
* {@link ChannelFutureProgressListener}. Please note that this method will
* not do anything and return {@code false} if this future is complete
* already.
*
* If it is success or failed already it will throw an {@link IllegalStateException}.
*/
void setProgress(long amount, long current, long total);
/**
* Notifies the progress of the operation to the listeners that implements
* {@link ChannelFutureProgressListener}. Please note that this method will
* not do anything and return {@code false} if this future is complete
* already.
*
* @return {@code true} if and only if notification was made.
*/
boolean tryProgress(long amount, long current, long total);
@Override
ChannelPromise addListener(ChannelFutureListener listener);

View File

@ -22,16 +22,6 @@ abstract class CompleteChannelPromise extends CompleteChannelFuture implements C
super(channel);
}
@Override
public void setProgress(long amount, long current, long total) {
throw new IllegalStateException();
}
@Override
public boolean tryProgress(long amount, long current, long total) {
return false;
}
@Override
public void setFailure(Throwable cause) {
throw new IllegalStateException();

View File

@ -20,7 +20,6 @@ import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -47,7 +46,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro
private ChannelFutureListener firstListener;
private List<ChannelFutureListener> otherListeners;
private List<ChannelFutureProgressListener> progressListeners;
private boolean done;
private Throwable cause;
private int waiters;
@ -106,13 +104,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro
}
otherListeners.add(listener);
}
if (listener instanceof ChannelFutureProgressListener) {
if (progressListeners == null) {
progressListeners = new ArrayList<ChannelFutureProgressListener>(1);
}
progressListeners.add((ChannelFutureProgressListener) listener);
}
}
}
@ -155,10 +146,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro
} else if (otherListeners != null) {
otherListeners.remove(listener);
}
if (listener instanceof ChannelFutureProgressListener) {
progressListeners.remove(listener);
}
}
}
@ -477,73 +464,6 @@ public class DefaultChannelPromise extends FlushCheckpoint implements ChannelPro
}
}
@Override
public void setProgress(long amount, long current, long total) {
ChannelFutureProgressListener[] plisteners;
synchronized (this) {
// Do not generate progress event after completion.
if (done) {
throw new IllegalStateException();
}
Collection<ChannelFutureProgressListener> progressListeners =
this.progressListeners;
if (progressListeners == null || progressListeners.isEmpty()) {
// Nothing to notify - no need to create an empty array.
return;
}
plisteners = progressListeners.toArray(
new ChannelFutureProgressListener[progressListeners.size()]);
}
for (ChannelFutureProgressListener pl: plisteners) {
notifyProgressListener(pl, amount, current, total);
}
}
@Override
public boolean tryProgress(long amount, long current, long total) {
ChannelFutureProgressListener[] plisteners;
synchronized (this) {
// Do not generate progress event after completion.
if (done) {
return false;
}
Collection<ChannelFutureProgressListener> progressListeners =
this.progressListeners;
if (progressListeners == null || progressListeners.isEmpty()) {
// Nothing to notify - no need to create an empty array.
return true;
}
plisteners = progressListeners.toArray(
new ChannelFutureProgressListener[progressListeners.size()]);
}
for (ChannelFutureProgressListener pl: plisteners) {
notifyProgressListener(pl, amount, current, total);
}
return true;
}
private void notifyProgressListener(
ChannelFutureProgressListener l,
long amount, long current, long total) {
try {
l.operationProgressed(this, amount, current, total);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureProgressListener.class.getSimpleName() + '.', t);
}
}
}
@Override
long flushCheckpoint() {
return flushCheckpoint;

View File

@ -126,11 +126,6 @@ final class VoidChannelPromise implements ChannelFuture.Unsafe, ChannelPromise {
fail();
return this;
}
@Override
public void setProgress(long amount, long current, long total) {
}
@Override
public void setFailure(Throwable cause) {
}
@ -139,11 +134,6 @@ final class VoidChannelPromise implements ChannelFuture.Unsafe, ChannelPromise {
public void setSuccess() {
}
@Override
public boolean tryProgress(long amount, long current, long total) {
return false;
}
@Override
public boolean tryFailure(Throwable cause) {
return false;