本文整理了Java中com.google.common.util.concurrent.Monitor.isOccupiedByCurrentThread()
方法的一些代码示例,展示了Monitor.isOccupiedByCurrentThread()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Monitor.isOccupiedByCurrentThread()
方法的具体详情如下:
包路径:com.google.common.util.concurrent.Monitor
类名称:Monitor
方法名:isOccupiedByCurrentThread
[英]Returns whether the current thread is occupying this monitor (has entered more times than it has left).
[中]返回当前线程是否占用此监视器(输入的次数多于离开的次数)。
代码示例来源:origin: google/guava
/**
* Attempts to execute all the listeners in {@link #listeners} while not holding the {@link
* #monitor}.
*/
private void dispatchListenerEvents() {
if (!monitor.isOccupiedByCurrentThread()) {
listeners.dispatch();
}
}
代码示例来源:origin: google/guava
/** Attempts to execute all the listeners in {@link #listeners}. */
void dispatchListenerEvents() {
checkState(
!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
listeners.dispatch();
}
代码示例来源:origin: google/j2objc
/**
* Attempts to execute all the listeners in {@link #listeners} while not holding the {@link
* #monitor}.
*/
private void dispatchListenerEvents() {
if (!monitor.isOccupiedByCurrentThread()) {
listeners.dispatch();
}
}
代码示例来源:origin: google/j2objc
/** Attempts to execute all the listeners in {@link #listeners}. */
void dispatchListenerEvents() {
checkState(
!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
listeners.dispatch();
}
代码示例来源:origin: wildfly/wildfly
/** Attempts to execute all the listeners in {@link #listeners}. */
void dispatchListenerEvents() {
checkState(
!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
listeners.dispatch();
}
代码示例来源:origin: wildfly/wildfly
/**
* Attempts to execute all the listeners in {@link #listeners} while not holding the {@link
* #monitor}.
*/
private void dispatchListenerEvents() {
if (!monitor.isOccupiedByCurrentThread()) {
listeners.dispatch();
}
}
代码示例来源:origin: google/guava
@Override
public void run() {
try {
actualIsOccupied.set(monitor.isOccupied());
actualIsOccupiedByCurrentThread.set(monitor.isOccupiedByCurrentThread());
actualOccupiedDepth.set(monitor.getOccupiedDepth());
} catch (Throwable t) {
thrown.set(t);
}
}
}));
代码示例来源:origin: google/guava
private void runEnterTest() {
assertFalse(Thread.currentThread().isInterrupted());
assertFalse(monitor.isOccupiedByCurrentThread());
doEnterScenarioSetUp();
boolean interruptedBeforeCall = Thread.currentThread().isInterrupted();
Outcome actualOutcome = doCall();
boolean occupiedAfterCall = monitor.isOccupiedByCurrentThread();
boolean interruptedAfterCall = Thread.currentThread().isInterrupted();
if (occupiedAfterCall) {
guard.setSatisfied(true);
monitor.leave();
assertFalse(monitor.isOccupiedByCurrentThread());
}
assertEquals(expectedOutcome, actualOutcome);
assertEquals(expectedOutcome == Outcome.SUCCESS, occupiedAfterCall);
assertEquals(
interruptedBeforeCall && expectedOutcome != Outcome.INTERRUPT, interruptedAfterCall);
}
代码示例来源:origin: google/guava
private void runWaitTest() {
assertFalse(Thread.currentThread().isInterrupted());
assertFalse(monitor.isOccupiedByCurrentThread());
monitor.enter();
try {
assertTrue(monitor.isOccupiedByCurrentThread());
doWaitScenarioSetUp();
boolean interruptedBeforeCall = Thread.currentThread().isInterrupted();
Outcome actualOutcome = doCall();
boolean occupiedAfterCall = monitor.isOccupiedByCurrentThread();
boolean interruptedAfterCall = Thread.currentThread().isInterrupted();
assertEquals(expectedOutcome, actualOutcome);
assertTrue(occupiedAfterCall);
assertEquals(
interruptedBeforeCall && expectedOutcome != Outcome.INTERRUPT, interruptedAfterCall);
} finally {
guard.setSatisfied(true);
monitor.leave();
assertFalse(monitor.isOccupiedByCurrentThread());
}
}
代码示例来源:origin: google/guava
private static void verifyOccupiedMethodsInCurrentThread(
Monitor monitor,
boolean expectedIsOccupied,
boolean expectedIsOccupiedByCurrentThread,
int expectedOccupiedDepth) {
assertEquals(expectedIsOccupied, monitor.isOccupied());
assertEquals(expectedIsOccupiedByCurrentThread, monitor.isOccupiedByCurrentThread());
assertEquals(expectedOccupiedDepth, monitor.getOccupiedDepth());
}
代码示例来源:origin: lenskit/lenskit
@Override
public boolean block() throws InterruptedException {
if (!monitor.isOccupiedByCurrentThread())
monitor.enter();
return true;
}
代码示例来源:origin: lenskit/lenskit
@Override
public boolean isReleasable() {
return monitor.isOccupiedByCurrentThread() || monitor.tryEnter();
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Attempts to execute all the listeners in {@link #listeners} while not holding the {@link
* #monitor}.
*/
private void dispatchListenerEvents() {
if (!monitor.isOccupiedByCurrentThread()) {
listeners.dispatch();
}
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Attempts to execute all the listeners in {@link #listeners} while not holding the
* {@link #monitor}.
*/
private void executeListeners() {
if (!monitor.isOccupiedByCurrentThread()) {
// iterate by index to avoid concurrent modification exceptions
for (int i = 0; i < listeners.size(); i++) {
listeners.get(i).execute();
}
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/** Attempts to execute all the listeners in {@link #listeners}. */
void dispatchListenerEvents() {
checkState(
!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
listeners.dispatch();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** Attempts to execute all the listeners in {@link #queuedListeners}. */
private void executeListeners() {
checkState(!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
queuedListeners.execute();
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Attempts to execute all the listeners in {@link #queuedListeners} while not holding the
* {@link #monitor}.
*/
private void executeListeners() {
if (!monitor.isOccupiedByCurrentThread()) {
queuedListeners.execute();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Attempts to execute all the listeners in {@link #queuedListeners} while not holding the
* {@link #monitor}.
*/
private void executeListeners() {
if (!monitor.isOccupiedByCurrentThread()) {
queuedListeners.execute();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/** Attempts to execute all the listeners in {@link #queuedListeners}. */
private void executeListeners() {
checkState(!monitor.isOccupiedByCurrentThread(),
"It is incorrect to execute listeners with the monitor held.");
queuedListeners.execute();
}
}
代码示例来源:origin: com.google.guava/guava-tests
@Override public void run() {
try {
actualIsOccupied.set(monitor.isOccupied());
actualIsOccupiedByCurrentThread.set(monitor.isOccupiedByCurrentThread());
actualOccupiedDepth.set(monitor.getOccupiedDepth());
} catch (Throwable t) {
thrown.set(t);
}
}
}));
内容来源于网络,如有侵权,请联系作者删除!