- Common ways to obtain Driver
private void myMethod () {Driver d =
DriverFactory driverFactory;DriverContext driverContext;driverFactory.createDriver(driverContext)
- Smart code suggestions by Codota
}
while (System.nanoTime() - start < maxRuntime && !isFinishedInternal());
public boolean isFinished() { checkLockNotHeld("Can not check finished status while holding the driver lock"); // if we can get the lock, attempt a clean shutdown; otherwise someone else will shutdown try (DriverLockResult lockResult = tryLockAndProcessPendingStateChanges(0, TimeUnit.MILLISECONDS)) { if (lockResult.wasAcquired()) { return isFinishedInternal(); } else { // did not get the lock, so we can't check operators, or destroy return state.get() != State.ALIVE || driverContext.isDone(); } } }
public ListenableFuture<?> processFor(Duration duration) { checkLockNotHeld("Can not process for a duration while holding the driver lock"); requireNonNull(duration, "duration is null"); long maxRuntime = duration.roundTo(TimeUnit.NANOSECONDS); try (DriverLockResult lockResult = tryLockAndProcessPendingStateChanges(100, TimeUnit.MILLISECONDS)) { if (lockResult.wasAcquired()) { driverContext.startProcessTimer(); try { long start = System.nanoTime(); do { ListenableFuture<?> future = processInternal(); if (!future.isDone()) { return future; } } while (System.nanoTime() - start < maxRuntime && !isFinishedInternal()); } finally { driverContext.recordProcessed(); } } } return NOT_BLOCKED; }