本文整理了Java中com.google.common.util.concurrent.Monitor.enterIf()
方法的一些代码示例,展示了Monitor.enterIf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Monitor.enterIf()
方法的具体详情如下:
包路径:com.google.common.util.concurrent.Monitor
类名称:Monitor
方法名:enterIf
[英]Enters this monitor if the guard is satisfied. Blocks indefinitely acquiring the lock, but does not wait for the guard to be satisfied.
[中]如果警卫满意,则进入该监视器。无限期阻止获取锁,但不等待警卫满意。
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
@Override
public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
enqueueStartingEvent();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
dispatchListenerEvents();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: google/j2objc
@CanIgnoreReturnValue
@Override
public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
enqueueStartingEvent();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
dispatchListenerEvents();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: wildfly/wildfly
@CanIgnoreReturnValue
@Override
public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
enqueueStartingEvent();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
dispatchListenerEvents();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
@Override
public final Service stopAsync() {
if (monitor.enterIf(isStoppable)) {
try {
State previous = state();
代码示例来源:origin: google/j2objc
@CanIgnoreReturnValue
@Override
public final Service stopAsync() {
if (monitor.enterIf(isStoppable)) {
try {
State previous = state();
代码示例来源:origin: wildfly/wildfly
@CanIgnoreReturnValue
@Override
public final Service stopAsync() {
if (monitor.enterIf(isStoppable)) {
try {
State previous = state();
代码示例来源:origin: stackoverflow.com
monitor.enterIf(notPaused);
try {
isPaused = true;
monitor.enterIf(paused);
try {
isPaused = false;
代码示例来源:origin: bbejeck/guava-blog
public void demoEnterIf() throws InterruptedException {
if (monitor.enterIf(conditionGuard)) {
try {
taskDoneCounter++;
if (taskDoneCounter == stopTaskCount) {
condition = false;
}
} finally {
monitor.leave();
}
} else {
taskSkippedCounter.incrementAndGet();
}
}
代码示例来源:origin: com.google.guava/guava-tests
@Override
public E peek() {
final Monitor monitor = this.monitor;
if (monitor.enterIf(notEmpty)) {
try {
return items[takeIndex];
} finally {
monitor.leave();
}
} else {
return null;
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Deprecated
@Override
public final ListenableFuture<State> start() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
}
return startup;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Deprecated
@Override
public final ListenableFuture<State> start() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
}
return startup;
}
代码示例来源:origin: Nextdoor/bender
@Deprecated
@Override
public final ListenableFuture<State> start() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
}
return startup;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
@Override public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
// TODO(user): justify why we are catching Throwable and not RuntimeException
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: com.diffplug.guava/guava-concurrent
@Override
public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
@Deprecated
@Override
public final ListenableFuture<State> start() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
}
return startup;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Deprecated
@Override
public final ListenableFuture<State> start() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
}
return startup;
}
代码示例来源:origin: com.google.guava/guava-tests
@Override
public E poll() {
final Monitor monitor = this.monitor;
if (monitor.enterIf(notEmpty)) {
try {
return extract();
} finally {
monitor.leave();
}
} else {
return null;
}
}
代码示例来源:origin: com.google.guava/guava-jdk5
@Override public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
// TODO(user): justify why we are catching Throwable and not RuntimeException
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
// TODO(user): justify why we are catching Throwable and not RuntimeException
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
代码示例来源:origin: Nextdoor/bender
@Override public final Service startAsync() {
if (monitor.enterIf(isStartable)) {
try {
snapshot = new StateSnapshot(STARTING);
starting();
doStart();
// TODO(user): justify why we are catching Throwable and not RuntimeException
} catch (Throwable startupFailure) {
notifyFailed(startupFailure);
} finally {
monitor.leave();
executeListeners();
}
} else {
throw new IllegalStateException("Service " + this + " has already been started");
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!