Package com.intellij.util.concurrency

Examples of com.intellij.util.concurrency.Semaphore


                                    final @Nullable XExpression xExpression) {
    final String evalText = xExpression == null ? null : xExpression.getExpression();
    if (topFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null;

    final Ref<String> evalResult = new Ref<String>();
    final Semaphore semaphore = new Semaphore();
    semaphore.down();

    try {
      myDebugProcess.getVmConnection().evaluateOnCallFrame(isolate, topFrame, evalText, new VmCallback<VmValue>() {
        public void handleResult(final VmResult<VmValue> result) {
          final VmValue vmValue = result.getResult();
          if (vmValue != null) {
            evalResult.set(vmValue.getText());
          }
          semaphore.up();
        }
      });
    }
    catch (IOException e) {/**/}

    semaphore.waitFor(1000);
    return evalResult.get();
  }
View Full Code Here


    if (!line.needAddPlatform()) {
      return true;
    }

    final Project project = configuration.getProject();
    final Semaphore targetDone = new Semaphore();
    final Ref<Boolean> result = new Ref<Boolean>(true);
    final List<Exception> exceptions = new ArrayList<Exception>();
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      public void run() {

        //Save all opened documents
        FileDocumentManager.getInstance().saveAllDocuments();
        targetDone.down();

        new Task.Backgroundable(project, "Init PhoneGap/Cordova platform", true) {

          public boolean shouldStartInBackground() {
            return true;
          }

          public void run(@NotNull final ProgressIndicator indicator) {
            try {
              String platform = phoneGapRunConfiguration.getPlatform();
              assert platform != null;
              ProcessOutput output = line.platformAdd(platform);
              if (output.getExitCode() != 0) {
                ExecutionHelper.showOutput(project, output, "Init PhoneGap/Cordova platform", null, true);
                result.set(false);
                targetDone.up();
                return;
              }

              targetDone.up();
            }
            catch (final ExecutionException e) {
              exceptions.add(e);
              result.set(false);
              targetDone.up();
            }
          }
        }.queue();
      }
    }, ModalityState.NON_MODAL);
    targetDone.waitFor();
    if (!exceptions.isEmpty()) {
      ExecutionHelper.showErrors(project, exceptions, "Cannot Init Platform", null);
    }

View Full Code Here

    return list.isEmpty()? null : list.removeLast();
  }

  public static void invokeAndWait(boolean timed, final Runnable runnable) {
    if (timed) {
      final Semaphore semaphore = new Semaphore();
      semaphore.down();
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          runnable.run();
          semaphore.up();
        }
      });
      semaphore.waitFor(1000);
      return;
    }

    try {
      SwingUtilities.invokeAndWait(runnable);
View Full Code Here

  private final Semaphore    myWaitSemaphore;
  private ProcessListener myEventMulticaster;

  protected ProcessHandler() {
    myEventMulticaster = createEventMulticaster();
    myWaitSemaphore = new Semaphore();
    myWaitSemaphore.down();
  }
View Full Code Here

TOP

Related Classes of com.intellij.util.concurrency.Semaphore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.