diff options
author | Marc Laukien <marc@zeroc.com> | 2003-03-07 21:01:54 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-03-07 21:01:54 +0000 |
commit | 32f22b8e2fc7aa3e889d719ef4b9e658d1a9ba27 (patch) | |
tree | 0af1f0e23cf7cf78671e157888d8f23c51e97f8f /java/src/IceInternal/ThreadPool.java | |
parent | internal changes (diff) | |
download | ice-32f22b8e2fc7aa3e889d719ef4b9e658d1a9ba27.tar.bz2 ice-32f22b8e2fc7aa3e889d719ef4b9e658d1a9ba27.tar.xz ice-32f22b8e2fc7aa3e889d719ef4b9e658d1a9ba27.zip |
internal changes
Diffstat (limited to 'java/src/IceInternal/ThreadPool.java')
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 64e36982523..d3f6908a5e5 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -215,15 +215,20 @@ public final class ThreadPool { if(_sizeMax > 1) { - if(!_promote) // Double-checked locking. + synchronized(_promoteMonitor) { - synchronized(_promoteMonitor) + assert(!_promote); + _promote = true; + _promoteMonitor.notify(); + + assert(_inUse >= 0); + ++_inUse; + + if(_inUse == _sizeWarn) { - if(!_promote) - { - _promote = true; - _promoteMonitor.notify(); - } + String s = "thread pool `" + _prefix + "' is running low on threads\n" + + "Size=" + _size + ", " + "SizeMax=" + _sizeMax + ", " + "SizeWarn=" + _sizeWarn; + _instance.logger().warning(s); } } } @@ -648,6 +653,9 @@ public final class ThreadPool { synchronized(_promoteMonitor) { + assert(_inUse > 0); + --_inUse; + while(!_promote) { try @@ -921,7 +929,6 @@ public final class ThreadPool private final int _sizeMax; // Maximum number of threads. private final int _sizeWarn; // If _inUse reaches _sizeWarn, a "low on threads" warning will be printed. private int _inUse; // Number of threads that are currently in use. - private java.lang.Object _inUseMutex = new java.lang.Object(); private java.nio.channels.ReadableByteChannel _fdIntrRead; private java.nio.channels.SelectionKey _fdIntrReadKey; @@ -974,7 +981,19 @@ public final class ThreadPool trace("run() terminated - promoting follower"); } - promoteFollower(); + // + // Promote a follower, but w/o modifying _inUse or + // creating new threads. + // + if(_sizeMax > 1) + { + synchronized(_promoteMonitor) + { + assert(!_promote); + _promote = true; + _promoteMonitor.notify(); + } + } stream.destroy(); } |