Small optimization when starting reserved threads.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
00d977d5d5
commit
31e5531966
|
@ -231,14 +231,15 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
// Not atomic, but there is a re-check in ReservedThread.run().
|
||||||
int pending = _pending.get();
|
int pending = _pending.get();
|
||||||
if (pending >= _capacity)
|
int size = _size.get();
|
||||||
|
if (pending + size >= _capacity)
|
||||||
return;
|
return;
|
||||||
if (_pending.compareAndSet(pending, pending + 1))
|
if (_pending.compareAndSet(pending, pending + 1))
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} startReservedThread p={}", this, pending + 1);
|
LOG.debug("{} startReservedThread p={}", this, pending + 1);
|
||||||
|
|
||||||
_executor.execute(new ReservedThread());
|
_executor.execute(new ReservedThread());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue