shz.core.lock.LockHolder Maven / Gradle / Ivy
package shz.core.lock;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
public interface LockHolder {
R applyRead(Supplier extends R> supplier, long time, TimeUnit unit);
default R applyRead(Supplier extends R> supplier) {
return applyRead(supplier, 0L, TimeUnit.MILLISECONDS);
}
void acceptRead(Runnable runnable, long time, TimeUnit unit);
default void acceptRead(Runnable runnable) {
acceptRead(runnable, 0L, TimeUnit.MILLISECONDS);
}
R applyWrite(Supplier extends R> supplier, long time, TimeUnit unit);
default R applyWrite(Supplier extends R> supplier) {
return applyWrite(supplier, 0L, TimeUnit.MILLISECONDS);
}
void acceptWrite(Runnable runnable, long time, TimeUnit unit);
default void acceptWrite(Runnable runnable) {
acceptWrite(runnable, 0L, TimeUnit.MILLISECONDS);
}
}