コード例 #1
0
  public synchronized void addItem(final CompletionResult item) {
    if (!isRunning()) return;
    ProgressManager.checkCanceled();

    final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
    if (!unitTestMode) {
      LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
    }

    LOG.assertTrue(myParameters.getPosition().isValid());

    myItemSorters.put(item.getLookupElement(), (CompletionSorterImpl) item.getSorter());
    myLookup.addItem(item.getLookupElement(), item.getPrefixMatcher());
    myCount++;

    if (myCount == 1) {
      ApplicationManager.getApplication()
          .executeOnPooledThread(
              new Runnable() {
                public void run() {
                  try {
                    Thread.sleep(300);
                  } catch (InterruptedException ignore) {
                  } finally {
                    myFreezeSemaphore.up();
                  }
                }
              });
    }
    myQueue.queue(myUpdate);
  }
コード例 #2
0
  public synchronized void addItem(final CompletionResult item) {
    if (!isRunning()) return;
    ProgressManager.checkCanceled();

    final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
    if (!unitTestMode) {
      LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
    }

    LOG.assertTrue(myParameters.getPosition().isValid());

    myItemSorters.put(item.getLookupElement(), (CompletionSorterImpl) item.getSorter());
    myLookup.addItem(item.getLookupElement(), item.getPrefixMatcher());
    myCount++;

    if (myCount == 1) {
      new Alarm(Alarm.ThreadToUse.SHARED_THREAD, this)
          .addRequest(
              new Runnable() {
                @Override
                public void run() {
                  myFreezeSemaphore.up();
                }
              },
              300);
    }
    myQueue.queue(myUpdate);
  }