本文整理汇总了Java中com.intellij.util.concurrency.Semaphore.down方法的典型用法代码示例。如果您正苦于以下问题:Java Semaphore.down方法的具体用法?Java Semaphore.down怎么用?Java Semaphore.down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.concurrency.Semaphore
的用法示例。
在下文中一共展示了Semaphore.down方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: smartInvokeAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public static void smartInvokeAndWait(final Project p, final ModalityState state, final Runnable r) {
if (isNoBackgroundMode() || ApplicationManager.getApplication().isDispatchThread()) {
r.run();
} else {
final Semaphore semaphore = new Semaphore();
semaphore.down();
DumbService.getInstance(p).smartInvokeLater(() -> {
try {
r.run();
} finally {
semaphore.up();
}
}, state);
semaphore.waitFor();
}
}
示例2: SvnCopiesRefreshManager
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public SvnCopiesRefreshManager(final SvnFileUrlMappingImpl mapping) {
mySemaphore = new Semaphore();
// svn mappings refresh inside also uses asynchronous pass -> we need to pass callback that will ping our "single-threaded" executor here
myMappingCallback = new Runnable() {
@Override
public void run() {
mySemaphore.up();
}
};
myRequestsMerger = new RequestsMerger(new Runnable() {
@Override
public void run() {
mySemaphore.down();
mapping.realRefresh(myMappingCallback);
mySemaphore.waitFor();
}
}, new Consumer<Runnable>() {
public void consume(final Runnable runnable) {
ApplicationManager.getApplication().executeOnPooledThread(runnable);
}
});
}
示例3: waitForSmartMode
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
public void waitForSmartMode() {
if (!isDumb()) {
return;
}
final Application application = ApplicationManager.getApplication();
if (application.isReadAccessAllowed() || application.isDispatchThread()) {
throw new AssertionError("Don't invoke waitForSmartMode from inside read action in dumb mode");
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
runWhenSmart(new Runnable() {
@Override
public void run() {
semaphore.up();
}
});
while (true) {
if (semaphore.waitFor(50)) {
return;
}
ProgressManager.checkCanceled();
}
}
示例4: smartInvokeAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public static void smartInvokeAndWait(final Project p, final ModalityState state, final Runnable r) {
if (isNoBackgroundMode() || ApplicationManager.getApplication().isDispatchThread()) {
r.run();
}
else {
final Semaphore semaphore = new Semaphore();
semaphore.down();
DumbService.getInstance(p).smartInvokeLater(new Runnable() {
@Override
public void run() {
try {
r.run();
}
finally {
semaphore.up();
}
}
}, state);
semaphore.waitFor();
}
}
示例5: compute
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public T compute() {
final Semaphore semaphore = new Semaphore();
semaphore.down();
final AtomicReference<T> reference = new AtomicReference<T>();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
try {
reference.set(runImpl());
}
finally {
semaphore.up();
}
}
});
semaphore.waitFor();
return reference.get();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:BackgroundSynchronousInvisibleComputable.java
示例6: startAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public void startAndWait(final LineProcessEventListener listener) {
final Semaphore semaphore = new Semaphore();
semaphore.down();
addListener(new LineProcessEventListener() {
@Override
public void onLineAvailable(final String s, final Key key) {
listener.onLineAvailable(s, key);
}
@Override
public void processTerminated(final int i) {
listener.processTerminated(i);
semaphore.up();
}
@Override
public void startFailed(final Throwable throwable) {
listener.startFailed(throwable);
semaphore.up();
}
});
start();
semaphore.waitFor();
}
示例7: waitForProcess
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
private void waitForProcess(Application application) {
myWaitSemaphore = new Semaphore();
myWaitSemaphore.down();
myWaitForThreadFuture = application.executeOnPooledThread(new Runnable() {
public void run() {
try {
myProcess.waitFor();
}
catch (InterruptedException ignored) {
}
finally {
myWaitSemaphore.up();
}
}
});
}
示例8: waitForCompletion
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public void waitForCompletion() {
if (isStopped) return;
if (ApplicationManager.getApplication().isUnitTestMode()) {
synchronized (myQueue) {
while (!myQueue.isEmpty()) {
startProcessing(myQueue.poll());
}
}
return;
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
scheduleTask(new MavenProjectsProcessorTask() {
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator)
throws MavenProcessCanceledException {
semaphore.up();
}
});
while (true) {
if (isStopped || semaphore.waitFor(1000)) return;
}
}
示例9: waitUntilRefreshed
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public void waitUntilRefreshed() {
while (true) {
final Semaphore semaphore = new Semaphore();
synchronized (myLock) {
if (!myRequestSubmitted && !myRequestRunning) {
return;
}
semaphore.down();
myWaitingUpdateCompletionSemaphores.add(semaphore);
}
if (!semaphore.waitFor(100*1000)) {
LOG.error("Too long VCS update");
return;
}
}
}
示例10: waitFor
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public boolean waitFor(long msTimeout) {
if (isProcessed()) {
return true;
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
doWhenProcessed(semaphore::up);
try {
if (msTimeout == -1) {
semaphore.waitForUnsafe();
}
else if (!semaphore.waitForUnsafe(msTimeout)) {
reject("Time limit exceeded");
return false;
}
}
catch (InterruptedException e) {
reject(e.getMessage());
return false;
}
return true;
}
示例11: waitUntilRefreshed
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@TestOnly
public void waitUntilRefreshed() {
while (true) {
final Semaphore semaphore = new Semaphore();
synchronized (myLock) {
if (!myRequestSubmitted && !myRequestRunning) {
return;
}
if (!myRequestRunning) {
myScheduler.submit(new MyRunnable());
}
semaphore.down();
myWaitingUpdateCompletionSemaphores.add(semaphore);
}
if (!semaphore.waitFor(100*1000)) {
LOG.error("Too long VCS update");
return;
}
}
}
示例12: freeze
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public void freeze(@Nonnull String reason) {
myUpdater.setIgnoreBackgroundOperation(true);
Semaphore sem = new Semaphore();
sem.down();
invokeAfterUpdate(() -> {
myUpdater.setIgnoreBackgroundOperation(false);
myUpdater.pause();
myFreezeName.set(reason);
sem.up();
}, InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED, "", ModalityState.defaultModalityState());
boolean free = false;
while (!free) {
ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
if (pi != null) pi.checkCanceled();
free = sem.waitFor(500);
}
}
示例13: startThread
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
public Future<?> startThread(final ProgressIndicator progressIndicator, final Runnable runnable) {
final Semaphore startSemaphore = new Semaphore();
startSemaphore.down();
Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(() -> ProgressManager.getInstance().runProcess(() -> {
try {
ApplicationManager.getApplication().runReadAction(() -> {
startSemaphore.up();
ProgressManager.checkCanceled();
runnable.run();
});
} catch (ProcessCanceledException ignored) {
}
}, progressIndicator));
startSemaphore.waitFor();
return future;
}
示例14: refreshSvnMappingsSynchronously
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
protected void refreshSvnMappingsSynchronously() {
final SvnVcs vcs = SvnVcs.getInstance(myProject);
if (! myInitChangeListManager) {
return;
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(new Runnable() {
@Override
public void run() {
semaphore.up();
}
});
semaphore.waitFor();
}
示例15: close
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public static void close(final Process process) {
final Semaphore outerSemaphore = new Semaphore();
outerSemaphore.down();
final Application application = ApplicationManager.getApplication();
application.executeOnPooledThread(new Runnable() {
public void run() {
try {
final Semaphore semaphore = new Semaphore();
semaphore.down();
final Runnable closeRunnable = new Runnable() {
public void run() {
try {
closeProcessImpl(process);
}
finally {
semaphore.up();
}
}
};
final Future<?> innerFuture = application.executeOnPooledThread(closeRunnable);
semaphore.waitFor(ourAsynchronousWaitTimeout);
if ( ! (innerFuture.isDone() || innerFuture.isCancelled())) {
innerFuture.cancel(true); // will call interrupt()
}
}
finally {
outerSemaphore.up();
}
}
});
// just wait
outerSemaphore.waitFor(ourSynchronousWaitTimeout);
}