本文整理汇总了Java中com.github.davidmoten.guavamini.Optional.isPresent方法的典型用法代码示例。如果您正苦于以下问题:Java Optional.isPresent方法的具体用法?Java Optional.isPresent怎么用?Java Optional.isPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.davidmoten.guavamini.Optional
的用法示例。
在下文中一共展示了Optional.isPresent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startScheduledResetAgain
import com.github.davidmoten.guavamini.Optional; //导入方法依赖的package包/类
private static <T> void startScheduledResetAgain(final long duration, final TimeUnit unit,
final Scheduler scheduler, final AtomicReference<CachedObservable<T>> cacheRef,
final AtomicReference<Optional<Scheduler.Worker>> workerRef) {
Runnable action = new Runnable() {
@Override
public void run() {
cacheRef.get().reset();
}
};
// CAS loop to cancel the current worker and create a new one
while (true) {
Optional<Scheduler.Worker> wOld = workerRef.get();
if (wOld == null) {
// we are finished
return;
}
Optional<Scheduler.Worker> w = Optional.of(scheduler.createWorker());
if (workerRef.compareAndSet(wOld, w)) {
if (wOld.isPresent())
wOld.get().dispose();
w.get().schedule(action, duration, unit);
break;
}
}
}
示例2: startScheduledResetAgain
import com.github.davidmoten.guavamini.Optional; //导入方法依赖的package包/类
private static <T> void startScheduledResetAgain(final long duration, final TimeUnit unit,
final Scheduler scheduler, final AtomicReference<CachedFlowable<T>> cacheRef,
final AtomicReference<Optional<Scheduler.Worker>> workerRef) {
Runnable action = new Runnable() {
@Override
public void run() {
cacheRef.get().reset();
}
};
// CAS loop to cancel the current worker and create a new one
while (true) {
Optional<Scheduler.Worker> wOld = workerRef.get();
if (wOld == null) {
// we are finished
return;
}
Optional<Scheduler.Worker> w = Optional.of(scheduler.createWorker());
if (workerRef.compareAndSet(wOld, w)) {
if (wOld.isPresent())
wOld.get().dispose();
w.get().schedule(action, duration, unit);
break;
}
}
}