本文整理汇总了Java中com.intellij.util.concurrency.Semaphore.up方法的典型用法代码示例。如果您正苦于以下问题:Java Semaphore.up方法的具体用法?Java Semaphore.up怎么用?Java Semaphore.up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.concurrency.Semaphore
的用法示例。
在下文中一共展示了Semaphore.up方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
static void invokeAndWait(@NotNull final Runnable runnable, @NotNull ModalityState modalityState) {
LOG.assertTrue(!isDispatchThread());
final Semaphore semaphore = new Semaphore();
semaphore.down();
Runnable runnable1 = new Runnable() {
@Override
public void run() {
try {
runnable.run();
}
finally {
semaphore.up();
}
}
@Override
@NonNls
public String toString() {
return "InvokeAndWait[" + runnable + "]";
}
};
invokeLater(runnable1, modalityState);
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: invokeAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public static void invokeAndWait(@NotNull final Runnable runnable, @NotNull ModalityState modalityState) {
LOG.assertTrue(!isDispatchThread());
final Semaphore semaphore = new Semaphore();
semaphore.down();
Runnable runnable1 = new Runnable() {
@Override
public void run() {
try {
runnable.run();
}
finally {
semaphore.up();
}
}
@NonNls
public String toString() {
return "InvokeAndWait[" + runnable.toString() + "]";
}
};
invokeLater(runnable1, modalityState);
semaphore.waitFor();
}
示例4: run
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
protected void run(final Semaphore semaphore, final AtomicReference<T> result) {
if (myServer == null) {
semaphore.up();
return;
}
final ServerConnection<DC> connection = ServerConnectionManager.getInstance().createTemporaryConnection(myServer);
run(connection, semaphore, result);
}
示例5: stop
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
public synchronized void stop() {
if (myOriginal.isRunning()) {
myOriginal.stop();
}
else {
myStartupAlarm.cancelAllRequests();
if (!myOriginalStarted && myOriginal instanceof Disposable) {
// dispose original because start & stop were not called so original progress might not have released its resources
Disposer.dispose(((Disposable)myOriginal));
}
}
// needed only for correct assertion of !progress.isRunning() in ApplicationImpl.runProcessWithProgressSynchroniously
final Semaphore semaphore = new Semaphore();
semaphore.down();
SwingUtilities.invokeLater(
new Runnable() {
@Override
public void run() {
semaphore.waitFor();
if (myDialog != null){
//System.out.println("myDialog.destroyProcess()");
myDialog.close(DialogWrapper.OK_EXIT_CODE);
myDialog = null;
}
}
}
);
try {
super.stop(); // should be last to not leaveModal before closing the dialog
}
finally {
semaphore.up();
}
}
示例6: freeSemaphores
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
private void freeSemaphores() {
synchronized (myLock) {
for (Semaphore semaphore : myWaitingUpdateCompletionSemaphores) {
semaphore.up();
}
myWaitingUpdateCompletionSemaphores.clear();
}
}
示例7: run
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
public void run() {
final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
final Semaphore done = new Semaphore();
final Runnable innerRunnable = new Runnable() {
@Override
public void run() {
try {
myRequestLock.lock();
myResult = executeRequestImpl(myCurrentServerUri, myCredentials, myRequest, pi);
}
catch (Exception e) {
LOG.warn(e);
myError = TfsExceptionManager.processException(e);
}
finally {
myRequestLock.unlock();
done.up();
}
}
};
pi.setIndeterminate(true);
done.down();
ApplicationManager.getApplication().executeOnPooledThread(innerRunnable);
while (!done.waitFor(POLL_TIMEOUT)) {
if (pi.isCanceled()) {
break;
}
}
}
示例8: stop
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public synchronized void stop() {
if (myOriginal.isRunning()) {
myOriginal.stop();
}
else {
myStartupAlarm.cancelAllRequests();
if (!myOriginalStarted && myOriginal instanceof Disposable) {
// dispose original because start & stop were not called so original progress might not have released its resources
Disposer.dispose(((Disposable)myOriginal));
}
}
// needed only for correct assertion of !progress.isRunning() in ApplicationImpl.runProcessWithProgressSynchroniously
final Semaphore semaphore = new Semaphore();
semaphore.down();
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
semaphore.waitFor();
if (myDialog != null){
//System.out.println("myDialog.destroyProcess()");
myDialog.close(DialogWrapper.OK_EXIT_CODE);
myDialog = null;
}
}
}
);
try {
super.stop(); // should be last to not leaveModal before closing the dialog
}
finally {
semaphore.up();
}
}
示例9: updateAllChanged
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public static void updateAllChanged(@NotNull final UpdatedFiles updatedFiles) {
FilesToRefreshCollector callback = new FilesToRefreshCollector();
UpdateFilesHelper.iterateFileGroupFilesDeletedOnServerFirst(updatedFiles, callback);
for (File file : callback.getToRefreshDeletedOrReplaced()) {
refreshDeletedOrReplaced(file);
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
LocalFileSystem.getInstance().refreshIoFiles(callback.getToRefresh(), false, false, null);
return;
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
try {
LocalFileSystem.getInstance().refreshIoFiles(callback.getToRefresh(), true, false, new Runnable() {
@Override
public void run() {
semaphore.up();
}
});
}
catch (Throwable t) {
semaphore.up();
throw new RuntimeException(t);
}
semaphore.waitFor();
}
示例10: invokeAndWait
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
static void invokeAndWait(@Nonnull final Runnable runnable, @Nonnull ModalityState modalityState) {
LOG.assertTrue(!isDispatchThread());
final Semaphore semaphore = new Semaphore();
semaphore.down();
final Ref<Throwable> exception = Ref.create();
Runnable runnable1 = new Runnable() {
@Override
public void run() {
try {
runnable.run();
}
catch (Throwable e) {
exception.set(e);
}
finally {
semaphore.up();
}
}
@Override
@NonNls
public String toString() {
return "InvokeAndWait[" + runnable + "]";
}
};
invokeLaterWithCallback(runnable1, modalityState, Conditions.FALSE, null);
semaphore.waitFor();
if (!exception.isNull()) {
Throwable cause = exception.get();
if (SystemPropertyUtil.getBoolean("invoke.later.wrap.error", true)) {
// wrap everything to keep the current thread stacktrace
// also TC ComparisonFailure feature depends on this
throw new RuntimeException(cause);
}
else {
ExceptionUtil.rethrow(cause);
}
}
}
示例11: stop
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
@Override
public synchronized void stop() {
if (myOriginal.isRunning()) {
myOriginal.stop();
}
else {
myStartupAlarm.cancel(false);
if (!myOriginalStarted && myOriginal instanceof Disposable) {
// dispose original because start & stop were not called so original progress might not have released its resources
Disposer.dispose(((Disposable)myOriginal));
}
}
// needed only for correct assertion of !progress.isRunning() in ApplicationImpl.runProcessWithProgressSynchroniously
final Semaphore semaphore = new Semaphore();
semaphore.down();
SwingUtilities.invokeLater(
new Runnable() {
@Override
public void run() {
semaphore.waitFor();
if (myDialog != null){
//System.out.println("myDialog.destroyProcess()");
myDialog.close(DialogWrapper.OK_EXIT_CODE);
myDialog = null;
}
}
}
);
try {
super.stop(); // should be last to not leaveModal before closing the dialog
}
finally {
semaphore.up();
}
}
示例12: doMake
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors, final boolean forceMakeProject) {
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
return true;
}
if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase)configuration).excludeCompileBeforeLaunchOption()) {
return true;
}
final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption)configuration;
final Ref<Boolean> result = new Ref<Boolean>(Boolean.FALSE);
try {
final Semaphore done = new Semaphore();
done.down();
final CompileStatusNotification callback = new CompileStatusNotification() {
public void finished(final boolean aborted, final int errors, final int warnings, CompileContext compileContext) {
if ((errors == 0 || ignoreErrors) && !aborted) {
result.set(Boolean.TRUE);
}
done.up();
}
};
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
CompileScope scope;
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
if (forceMakeProject) {
// user explicitly requested whole-project make
scope = compilerManager.createProjectCompileScope(myProject);
}
else {
final Module[] modules = runConfiguration.getModules();
if (modules.length > 0) {
for (Module module : modules) {
if (module == null) {
LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" +
runConfiguration.getClass().getName());
}
}
scope = compilerManager.createModulesCompileScope(modules, true, true);
}
else {
scope = compilerManager.createProjectCompileScope(myProject);
}
}
if (!myProject.isDisposed()) {
scope.putUserData(RUN_CONFIGURATION, configuration);
scope.putUserData(RUN_CONFIGURATION_TYPE_ID, configuration.getType().getId());
ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.set(scope, ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.get(env));
compilerManager.make(scope, callback);
}
else {
done.up();
}
}
});
done.waitFor();
}
catch (Exception e) {
return false;
}
return result.get();
}
示例13: testStatusDoesNotLockForWrite
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
public void testStatusDoesNotLockForWrite() throws Exception {
final File ioFile = new File(myWorkingCopyRoot, filename);
ioFile.getParentFile().mkdirs();
/*SVNWCClient client11 = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
client11.doAdd(ioFile.getParentFile(), true, false, true, true);*/
ioFile.createNewFile();
try {
final SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
final Semaphore semaphore = new Semaphore();
final Semaphore semaphoreMain = new Semaphore();
final Semaphore semaphoreWokeUp = new Semaphore();
final AtomicReference<Boolean> wasUp = new AtomicReference<Boolean>(false);
final ISVNStatusHandler handler = new ISVNStatusHandler() {
@Override
public void handleStatus(SVNStatus status) throws SVNException {
semaphore.waitFor();
wasUp.set(true);
}
};
semaphore.down();
semaphoreMain.down();
semaphoreWokeUp.down();
final SVNException[] exception = new SVNException[1];
new Thread(new Runnable() {
@Override
public void run() {
try {
semaphoreMain.up();
readClient.doStatus(myWorkingCopyRoot, true, false, true, false, handler);
semaphoreWokeUp.up();
}
catch (SVNException e) {
exception[0] = e;
}
}
},"svn test").start();
semaphoreMain.waitFor();
TimeoutUtil.sleep(5);
SVNWCClient client = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
client.doAdd(ioFile.getParentFile(), true, false, true, true);
semaphore.up();
semaphoreWokeUp.waitFor();
Assert.assertEquals(true, wasUp.get().booleanValue());
if (exception[0] != null) {
throw exception[0];
}
} finally {
ioFile.delete();
}
}
示例14: doMake
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors) {
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
return true;
}
if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase)configuration).excludeCompileBeforeLaunchOption()) {
return true;
}
final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption)configuration;
final Ref<Boolean> result = new Ref<Boolean>(Boolean.FALSE);
try {
final Semaphore done = new Semaphore();
done.down();
final CompileStatusNotification callback = new CompileStatusNotification() {
public void finished(final boolean aborted, final int errors, final int warnings, CompileContext compileContext) {
if ((errors == 0 || ignoreErrors) && !aborted) {
result.set(Boolean.TRUE);
}
done.up();
}
};
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
CompileScope scope;
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
if (Boolean.valueOf(System.getProperty(MAKE_PROJECT_ON_RUN_KEY, Boolean.FALSE.toString())).booleanValue()) {
// user explicitly requested whole-project make
scope = compilerManager.createProjectCompileScope(myProject);
}
else {
final Module[] modules = runConfiguration.getModules();
if (modules.length > 0) {
for (Module module : modules) {
if (module == null) {
LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" +
runConfiguration.getClass().getName());
}
}
scope = compilerManager.createModulesCompileScope(modules, true);
}
else {
scope = compilerManager.createProjectCompileScope(myProject);
}
}
if (!myProject.isDisposed()) {
scope.putUserData(RUN_CONFIGURATION, configuration);
scope.putUserData(RUN_CONFIGURATION_TYPE_ID, configuration.getType().getId());
compilerManager.make(scope, callback);
}
else {
done.up();
}
}
});
done.waitFor();
}
catch (Exception e) {
return false;
}
return result.get();
}
示例15: doMake
import com.intellij.util.concurrency.Semaphore; //导入方法依赖的package包/类
static boolean doMake(final Project myProject, final RunConfiguration configuration, final ExecutionEnvironment env, final boolean ignoreErrors) {
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
return true;
}
if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase)configuration).excludeCompileBeforeLaunchOption()) {
return true;
}
final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption)configuration;
final Ref<Boolean> result = new Ref<Boolean>(Boolean.FALSE);
try {
final Semaphore done = new Semaphore();
done.down();
final CompileStatusNotification callback = new CompileStatusNotification() {
@Override
public void finished(final boolean aborted, final int errors, final int warnings, CompileContext compileContext) {
if ((errors == 0 || ignoreErrors) && !aborted) {
result.set(Boolean.TRUE);
}
done.up();
}
};
TransactionGuard.submitTransaction(myProject, new Runnable() {
@Override
public void run() {
CompileScope scope;
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
if (Comparing.equal(Boolean.TRUE.toString(), System.getProperty(MAKE_PROJECT_ON_RUN_KEY))) {
// user explicitly requested whole-project make
scope = compilerManager.createProjectCompileScope();
}
else {
final Module[] modules = runConfiguration.getModules();
if (modules.length > 0) {
for (Module module : modules) {
if (module == null) {
LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" +
runConfiguration.getClass().getName());
}
}
scope = compilerManager.createModulesCompileScope(modules, true);
}
else {
scope = compilerManager.createProjectCompileScope();
}
}
if (!myProject.isDisposed()) {
scope.putUserData(RUN_CONFIGURATION, configuration);
scope.putUserData(RUN_CONFIGURATION_TYPE_ID, configuration.getType().getId());
scope.putUserData(RUNNER_ID, env.getRunnerId());
scope.putUserData(EXECUTOR, env.getExecutor());
compilerManager.make(scope, callback);
}
else {
done.up();
}
}
});
done.waitFor();
}
catch (Exception e) {
return false;
}
return result.get();
}