Ported the dead lock detector in DefaultChannelFuture to DefaultChannelGroupFuture.
This commit is contained in:
parent
563fd2c286
commit
c4ba12e8d4
@ -38,6 +38,7 @@ import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.IoWorkerRunnable;
|
||||
|
||||
/**
|
||||
* The default {@link ChannelGroupFuture} implementation.
|
||||
@ -210,6 +211,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
public ChannelGroupFuture await() throws InterruptedException {
|
||||
synchronized (this) {
|
||||
while (!done) {
|
||||
checkDeadLock();
|
||||
waiters++;
|
||||
try {
|
||||
this.wait();
|
||||
@ -233,6 +235,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
public ChannelGroupFuture awaitUninterruptibly() {
|
||||
synchronized (this) {
|
||||
while (!done) {
|
||||
checkDeadLock();
|
||||
waiters++;
|
||||
try {
|
||||
this.wait();
|
||||
@ -274,6 +277,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
return done;
|
||||
}
|
||||
|
||||
checkDeadLock();
|
||||
waiters++;
|
||||
try {
|
||||
for (;;) {
|
||||
@ -300,6 +304,14 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDeadLock() {
|
||||
if (IoWorkerRunnable.IN_IO_THREAD.get()) {
|
||||
throw new IllegalStateException(
|
||||
"await*() in I/O thread causes a dead lock or " +
|
||||
"sudden performance drop.");
|
||||
}
|
||||
}
|
||||
|
||||
boolean setDone() {
|
||||
synchronized (this) {
|
||||
// Allow only once.
|
||||
|
Loading…
Reference in New Issue
Block a user