Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2017 Fizzed, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fizzed.crux.util;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Basic abstraction of a spin-lock waiting for something to be true. Ideally
* you'd use real concurrent mechanisms, but that's not always available for
* things you need to evaluate.
*
* @author joelauer
*/
public class WaitFor {
static public class Progress {
final private int attempt;
final private TimeDuration timeout;
final private TimeDuration every;
final private StopWatch timer;
public Progress(int attempt, TimeDuration timeout, TimeDuration every, StopWatch timer) {
this.attempt = attempt;
this.timeout = timeout;
this.every = every;
this.timer = timer;
}
public int getAttempt() {
return attempt;
}
public TimeDuration getTimeout() {
return timeout;
}
public TimeDuration getEvery() {
return every;
}
public StopWatch getTimer() {
return timer;
}
}
private final Function