@Override public boolean isSatisfied() { return isSatisfied.getAsBoolean(); } };
@Override public boolean isSatisfied() { return isSatisfied.getAsBoolean(); } };
public boolean samplerCheck() { return sampler.getAsBoolean(); }
public static void awaitForever( BooleanSupplier condition, long checkInterval, TimeUnit unit ) { long sleep = unit.toNanos( checkInterval ); do { if ( condition.getAsBoolean() ) { return; } LockSupport.parkNanos( sleep ); } while ( true ); }
@Override public TransformationState<T> process(Optional<T> elementOptional) { if (!lastProcessYielded && yieldSignal.getAsBoolean()) { lastProcessYielded = true; return TransformationState.yield(); } lastProcessYielded = false; return elementOptional .map(TransformationState::ofResult) .orElseGet(TransformationState::finished); } }
private BooleanSupplier mergeEndCondition( BooleanSupplier additionalEndCondition ) { BooleanSupplier existingEndCondition = endCondition; return existingEndCondition == null ? additionalEndCondition : () -> existingEndCondition.getAsBoolean() || additionalEndCondition.getAsBoolean(); }
private static boolean sendFirst(final ArrayDeque<BooleanSupplier> responseQueue) { return responseQueue.peekFirst().getAsBoolean(); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @param message the message to be included in the {@code TestAbortedException} * if the assumption is invalid * @throws TestAbortedException if the assumption is not {@code true} */ public static void assumeTrue(BooleanSupplier assumptionSupplier, String message) throws TestAbortedException { assumeTrue(assumptionSupplier.getAsBoolean(), message); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @throws TestAbortedException if the assumption is not {@code true} */ public static void assumeTrue(BooleanSupplier assumptionSupplier) throws TestAbortedException { assumeTrue(assumptionSupplier.getAsBoolean(), "assumption is not true"); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @throws TestAbortedException if the assumption is not {@code false} */ public static void assumeFalse(BooleanSupplier assumptionSupplier) throws TestAbortedException { assumeFalse(assumptionSupplier.getAsBoolean(), "assumption is not false"); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @param message the message to be included in the {@code TestAbortedException} * if the assumption is invalid * @throws TestAbortedException if the assumption is not {@code false} */ public static void assumeFalse(BooleanSupplier assumptionSupplier, String message) throws TestAbortedException { assumeFalse(assumptionSupplier.getAsBoolean(), message); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @param messageSupplier the supplier of the message to be included in * the {@code TestAbortedException} if the assumption is invalid * @throws TestAbortedException if the assumption is not {@code true} */ public static void assumeTrue(BooleanSupplier assumptionSupplier, Supplier<String> messageSupplier) throws TestAbortedException { assumeTrue(assumptionSupplier.getAsBoolean(), messageSupplier); }
/** * Validate the given assumption. * * @param assumptionSupplier the supplier of the assumption to validate * @param messageSupplier the supplier of the message to be included in * the {@code TestAbortedException} if the assumption is invalid * @throws TestAbortedException if the assumption is not {@code false} */ public static void assumeFalse(BooleanSupplier assumptionSupplier, Supplier<String> messageSupplier) throws TestAbortedException { assumeFalse(assumptionSupplier.getAsBoolean(), messageSupplier); }
private static void awaitEvent(BooleanSupplier condition, long timeToWait, String description) { long timeToSleep = 200; for (int i = 0 ; i < Math.floor(timeToWait / timeToSleep); i++) { if (condition.getAsBoolean()) { return; } try { Thread.sleep(timeToSleep); } catch (InterruptedException e) { throw new IllegalStateException("Interrupted while waiting for " + description, e); } } throw new IllegalStateException("Timed out waiting for " + description); }
private void warnOnce(String propKey, String filePath, BooleanSupplier alreadyLoggedGetter, Runnable markAsLogged) { if (!alreadyLoggedGetter.getAsBoolean()) { String msg = "Specifying module-relative paths at project level in the property '" + propKey + "' is deprecated. " + "To continue matching files like '" + filePath + "', update this property so that patterns refer to project-relative paths."; LOG.warn(msg); analysisWarnings.addUnique(msg); markAsLogged.run(); } }
static void assertEventuallyTrue(BooleanSupplier predicate) throws Exception { // wait up to 3 seconds for (int i = 0; i < 30 && !predicate.getAsBoolean(); i++) { Thread.sleep(100); } Assert.assertTrue(predicate.getAsBoolean()); }
public static boolean waitUntil(BooleanSupplier supplier, long timeout) { long start = System.currentTimeMillis(); while (true) { if (supplier.getAsBoolean()) { return true; } try { Thread.sleep(10); } catch (InterruptedException ignore) { } long now = System.currentTimeMillis(); if (now - start > timeout) { return false; } } }
private void doEventLoopWaitUntil(long start, BooleanSupplier supplier, Runnable runner) { long now = System.currentTimeMillis(); if (now - start > 10000) { fail("Timedout in waiting until"); } else { if (supplier.getAsBoolean()) { runner.run(); } else { vertx.setTimer(1, tid -> doEventLoopWaitUntil(start, supplier, runner)); } } }
private void doWorkUntil(final BooleanSupplier condition, final LongConsumer timeConsumer) { while (!condition.getAsBoolean()) { final long millisecondsToAdvance = 16; currentTimeNs += TimeUnit.MILLISECONDS.toNanos(millisecondsToAdvance); currentTimeMs += millisecondsToAdvance; timeConsumer.accept(currentTimeNs); driverConductor.doWork(); } }
@Override public void run() { long latestTxId = TransactionIdStore.BASE_TX_ID; while ( condition.getAsBoolean() ) { TransactionToApply transaction = factory.nextTransaction( latestTxId ); try { latestTxId = transactionAppender.append( transaction, LogAppendEvent.NULL ); } catch ( IOException e ) { throw new RuntimeException( e ); } } } }