Skip to content

Commit

Permalink
HBASE-16846 Procedure v2 - executor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Bertozzi committed Oct 17, 2016
1 parent c8e9a29 commit c6e9dab
Show file tree
Hide file tree
Showing 14 changed files with 1,330 additions and 607 deletions.
Expand Up @@ -20,7 +20,6 @@


import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -123,17 +122,26 @@ public Procedure poll(long timeout, TimeUnit unit) {
return poll(unit.toNanos(timeout)); return poll(unit.toNanos(timeout));
} }


public Procedure poll(long nanos) { @edu.umd.cs.findbugs.annotations.SuppressWarnings("WA_AWAIT_NOT_IN_LOOP")
final boolean waitForever = (nanos < 0); public Procedure poll(final long nanos) {
schedLock(); schedLock();
try { try {
while (!queueHasRunnables()) { if (!running) {
if (!running) return null; LOG.debug("the scheduler is not running");
if (waitForever) { return null;
}

if (!queueHasRunnables()) {
// WA_AWAIT_NOT_IN_LOOP: we are not in a loop because we want the caller
// to take decisions after a wake/interruption.
if (nanos < 0) {
schedWaitCond.await(); schedWaitCond.await();
} else { } else {
if (nanos <= 0) return null; schedWaitCond.awaitNanos(nanos);
nanos = schedWaitCond.awaitNanos(nanos); }
if (!queueHasRunnables()) {
nullPollCalls++;
return null;
} }
} }


Expand Down

0 comments on commit c6e9dab

Please sign in to comment.