From 89a4bd9d4e5726f20f366ae0b306c447fd16d1b3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 17 Jul 2009 10:32:17 +0000 Subject: [PATCH] Added a global flag that disables the dead lock checker (use at your own risk) --- .../netty/channel/DefaultChannelFuture.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java b/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java index f6ffeec822..52618b7501 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelFuture.java @@ -50,6 +50,29 @@ public class DefaultChannelFuture implements ChannelFuture { private static final Throwable CANCELLED = new Throwable(); + private static volatile boolean useDeadLockChecker = true; + + /** + * Returns {@code true} if and only if the dead lock checker is enabled. + */ + public static boolean isUseDeadLockChecker() { + return useDeadLockChecker; + } + + /** + * Enables or disables the dead lock checker. It is not recommended to + * disable the dead lock checker. Disable it at your own risk! + */ + public static void setUseDeadLockChecker(boolean useDeadLockChecker) { + if (!useDeadLockChecker) { + logger.debug( + "The dead lock checker in " + + DefaultChannelFuture.class.getSimpleName() + + " has been disabled as requested at your own risk."); + } + DefaultChannelFuture.useDeadLockChecker = useDeadLockChecker; + } + private final Channel channel; private final boolean cancellable; @@ -239,7 +262,7 @@ public class DefaultChannelFuture implements ChannelFuture { } private void checkDeadLock() { - if (IoWorkerRunnable.IN_IO_THREAD.get()) { + if (isUseDeadLockChecker() && IoWorkerRunnable.IN_IO_THREAD.get()) { throw new IllegalStateException( "await*() in I/O thread causes a dead lock or " + "sudden performance drop. Use addListener() instead or " +