Tabnine Logo
Monitor$Guard.isSatisfied
Code IndexAdd Tabnine to your IDE (free)

How to use
isSatisfied
method
in
com.google.common.util.concurrent.Monitor$Guard

Best Java code snippets using com.google.common.util.concurrent.Monitor$Guard.isSatisfied (Showing top 20 results out of 315)

origin: google/guava

/**
 * Enters this monitor if the guard is satisfied. Blocks indefinitely acquiring the lock, but does
 * not wait for the guard to be satisfied.
 *
 * @return whether the monitor was entered, which guarantees that the guard is now satisfied
 */
public boolean enterIf(Guard guard) {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 lock.lock();
 boolean satisfied = false;
 try {
  return satisfied = guard.isSatisfied();
 } finally {
  if (!satisfied) {
   lock.unlock();
  }
 }
}
origin: google/guava

/**
 * Enters this monitor if the guard is satisfied. Blocks indefinitely acquiring the lock, but does
 * not wait for the guard to be satisfied, and may be interrupted.
 *
 * @return whether the monitor was entered, which guarantees that the guard is now satisfied
 * @throws InterruptedException if interrupted while waiting
 */
public boolean enterIfInterruptibly(Guard guard) throws InterruptedException {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 boolean satisfied = false;
 try {
  return satisfied = guard.isSatisfied();
 } finally {
  if (!satisfied) {
   lock.unlock();
  }
 }
}
origin: google/guava

/**
 * Enters this monitor if it is possible to do so immediately and the guard is satisfied. Does not
 * block acquiring the lock and does not wait for the guard to be satisfied.
 *
 * <p><b>Note:</b> This method disregards the fairness setting of this monitor.
 *
 * @return whether the monitor was entered, which guarantees that the guard is now satisfied
 */
public boolean tryEnterIf(Guard guard) {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 if (!lock.tryLock()) {
  return false;
 }
 boolean satisfied = false;
 try {
  return satisfied = guard.isSatisfied();
 } finally {
  if (!satisfied) {
   lock.unlock();
  }
 }
}
origin: google/j2objc

/**
 * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May
 * be called only by a thread currently occupying this monitor.
 *
 * @return whether the guard is now satisfied
 * @throws InterruptedException if interrupted while waiting
 */
public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException {
 final long timeoutNanos = toSafeNanos(time, unit);
 if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) {
  throw new IllegalMonitorStateException();
 }
 if (guard.isSatisfied()) {
  return true;
 }
 if (Thread.interrupted()) {
  throw new InterruptedException();
 }
 return awaitNanos(guard, timeoutNanos, true);
}
origin: google/guava

try {
 satisfied =
   guard.isSatisfied()
     || awaitNanos(
       guard,
origin: wildfly/wildfly

/**
 * Exactly like guard.isSatisfied(), but in addition signals all waiting threads in the (hopefully
 * unlikely) event that isSatisfied() throws.
 */
@GuardedBy("lock")
private boolean isSatisfied(Guard guard) {
 try {
  return guard.isSatisfied();
 } catch (Throwable throwable) {
  signalAllWaiters();
  throw Throwables.propagate(throwable);
 }
}
origin: wildfly/wildfly

/**
 * Waits for the guard to be satisfied. Waits indefinitely. May be called only by a thread
 * currently occupying this monitor.
 */
public void waitForUninterruptibly(Guard guard) {
 if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) {
  throw new IllegalMonitorStateException();
 }
 if (!guard.isSatisfied()) {
  awaitUninterruptibly(guard, true);
 }
}
origin: google/guava

 throw new IllegalMonitorStateException();
if (guard.isSatisfied()) {
 return true;
  } catch (InterruptedException interrupt) {
   interrupted = true;
   if (guard.isSatisfied()) {
    return true;
origin: google/j2objc

@GuardedBy("lock")
private void awaitUninterruptibly(Guard guard, boolean signalBeforeWaiting) {
 if (signalBeforeWaiting) {
  signalNextWaiter();
 }
 beginWaitingFor(guard);
 try {
  do {
   guard.condition.awaitUninterruptibly();
  } while (!guard.isSatisfied());
 } finally {
  endWaitingFor(guard);
 }
}
origin: google/guava

/**
 * Enters this monitor if the guard is satisfied. Blocks at most the given time acquiring the
 * lock, but does not wait for the guard to be satisfied, and may be interrupted.
 *
 * @return whether the monitor was entered, which guarantees that the guard is now satisfied
 */
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public boolean enterIfInterruptibly(Guard guard, long time, TimeUnit unit)
  throws InterruptedException {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 if (!lock.tryLock(time, unit)) {
  return false;
 }
 boolean satisfied = false;
 try {
  return satisfied = guard.isSatisfied();
 } finally {
  if (!satisfied) {
   lock.unlock();
  }
 }
}
origin: google/guava

 /** Caller should check before calling that guard is not satisfied. */
 @GuardedBy("lock")
 private boolean awaitNanos(Guard guard, long nanos, boolean signalBeforeWaiting)
   throws InterruptedException {
  boolean firstTime = true;
  try {
   do {
    if (nanos <= 0L) {
     return false;
    }
    if (firstTime) {
     if (signalBeforeWaiting) {
      signalNextWaiter();
     }
     beginWaitingFor(guard);
     firstTime = false;
    }
    nanos = guard.condition.awaitNanos(nanos);
   } while (!guard.isSatisfied());
   return true;
  } finally {
   if (!firstTime) {
    endWaitingFor(guard);
   }
  }
 }
}
origin: google/guava

/**
 * Enters this monitor when the guard is satisfied. Blocks indefinitely, but may be interrupted.
 *
 * @throws InterruptedException if interrupted while waiting
 */
public void enterWhen(Guard guard) throws InterruptedException {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 boolean signalBeforeWaiting = lock.isHeldByCurrentThread();
 lock.lockInterruptibly();
 boolean satisfied = false;
 try {
  if (!guard.isSatisfied()) {
   await(guard, signalBeforeWaiting);
  }
  satisfied = true;
 } finally {
  if (!satisfied) {
   leave();
  }
 }
}
origin: google/guava

/**
 * Enters this monitor if the guard is satisfied. Blocks at most the given time acquiring the
 * lock, but does not wait for the guard to be satisfied.
 *
 * @return whether the monitor was entered, which guarantees that the guard is now satisfied
 */
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public boolean enterIf(Guard guard, long time, TimeUnit unit) {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 if (!enter(time, unit)) {
  return false;
 }
 boolean satisfied = false;
 try {
  return satisfied = guard.isSatisfied();
 } finally {
  if (!satisfied) {
   lock.unlock();
  }
 }
}
origin: google/guava

/**
 * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May
 * be called only by a thread currently occupying this monitor.
 *
 * @return whether the guard is now satisfied
 * @throws InterruptedException if interrupted while waiting
 */
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException {
 final long timeoutNanos = toSafeNanos(time, unit);
 if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) {
  throw new IllegalMonitorStateException();
 }
 if (guard.isSatisfied()) {
  return true;
 }
 if (Thread.interrupted()) {
  throw new InterruptedException();
 }
 return awaitNanos(guard, timeoutNanos, true);
}
origin: google/guava

/** Enters this monitor when the guard is satisfied. Blocks indefinitely. */
public void enterWhenUninterruptibly(Guard guard) {
 if (guard.monitor != this) {
  throw new IllegalMonitorStateException();
 }
 final ReentrantLock lock = this.lock;
 boolean signalBeforeWaiting = lock.isHeldByCurrentThread();
 lock.lock();
 boolean satisfied = false;
 try {
  if (!guard.isSatisfied()) {
   awaitUninterruptibly(guard, signalBeforeWaiting);
  }
  satisfied = true;
 } finally {
  if (!satisfied) {
   leave();
  }
 }
}
origin: google/guava

@GuardedBy("lock")
private void await(Guard guard, boolean signalBeforeWaiting) throws InterruptedException {
 if (signalBeforeWaiting) {
  signalNextWaiter();
 }
 beginWaitingFor(guard);
 try {
  do {
   guard.condition.await();
  } while (!guard.isSatisfied());
 } finally {
  endWaitingFor(guard);
 }
}
origin: google/guava

/**
 * Waits for the guard to be satisfied. Waits indefinitely, but may be interrupted. May be called
 * only by a thread currently occupying this monitor.
 *
 * @throws InterruptedException if interrupted while waiting
 */
public void waitFor(Guard guard) throws InterruptedException {
 if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) {
  throw new IllegalMonitorStateException();
 }
 if (!guard.isSatisfied()) {
  await(guard, true);
 }
}
origin: google/guava

@GuardedBy("lock")
private void awaitUninterruptibly(Guard guard, boolean signalBeforeWaiting) {
 if (signalBeforeWaiting) {
  signalNextWaiter();
 }
 beginWaitingFor(guard);
 try {
  do {
   guard.condition.awaitUninterruptibly();
  } while (!guard.isSatisfied());
 } finally {
  endWaitingFor(guard);
 }
}
origin: google/guava

/**
 * Exactly like guard.isSatisfied(), but in addition signals all waiting threads in the (hopefully
 * unlikely) event that isSatisfied() throws.
 */
@GuardedBy("lock")
private boolean isSatisfied(Guard guard) {
 try {
  return guard.isSatisfied();
 } catch (Throwable throwable) {
  signalAllWaiters();
  throw throwable;
 }
}
origin: google/guava

/**
 * Waits for the guard to be satisfied. Waits indefinitely. May be called only by a thread
 * currently occupying this monitor.
 */
public void waitForUninterruptibly(Guard guard) {
 if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) {
  throw new IllegalMonitorStateException();
 }
 if (!guard.isSatisfied()) {
  awaitUninterruptibly(guard, true);
 }
}
com.google.common.util.concurrentMonitor$GuardisSatisfied

Javadoc

Evaluates this guard's boolean condition. This method is always called with the associated monitor already occupied. Implementations of this method must depend only on state protected by the associated monitor, and must not modify that state.

Popular methods of Monitor$Guard

    Popular in Java

    • Updating database using SQL prepared statement
    • getContentResolver (Context)
    • getExternalFilesDir (Context)
    • compareTo (BigDecimal)
    • RandomAccessFile (java.io)
      Allows reading from and writing to a file in a random-access manner. This is different from the uni-
    • BigDecimal (java.math)
      An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
    • MalformedURLException (java.net)
      This exception is thrown when a program attempts to create an URL from an incorrect specification.
    • Queue (java.util)
      A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
    • ZipFile (java.util.zip)
      This class provides random read access to a zip file. You pay more to read the zip file's central di
    • HttpServlet (javax.servlet.http)
      Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
    • Top Vim plugins
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now