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.channel.ChannelFutureListener;
|
||||||
import org.jboss.netty.logging.InternalLogger;
|
import org.jboss.netty.logging.InternalLogger;
|
||||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||||
|
import org.jboss.netty.util.internal.IoWorkerRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link ChannelGroupFuture} implementation.
|
* The default {@link ChannelGroupFuture} implementation.
|
||||||
@ -210,6 +211,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
public ChannelGroupFuture await() throws InterruptedException {
|
public ChannelGroupFuture await() throws InterruptedException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
checkDeadLock();
|
||||||
waiters++;
|
waiters++;
|
||||||
try {
|
try {
|
||||||
this.wait();
|
this.wait();
|
||||||
@ -233,6 +235,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
public ChannelGroupFuture awaitUninterruptibly() {
|
public ChannelGroupFuture awaitUninterruptibly() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
checkDeadLock();
|
||||||
waiters++;
|
waiters++;
|
||||||
try {
|
try {
|
||||||
this.wait();
|
this.wait();
|
||||||
@ -274,6 +277,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkDeadLock();
|
||||||
waiters++;
|
waiters++;
|
||||||
try {
|
try {
|
||||||
for (;;) {
|
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() {
|
boolean setDone() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// Allow only once.
|
// Allow only once.
|
||||||
|
Loading…
Reference in New Issue
Block a user