com.intellij.openapi.application.impl.LaterInvocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-impl Show documentation
Show all versions of platform-impl Show documentation
A packaging of the IntelliJ Community Edition platform-impl library.
This is release number 1 of trunk branch 142.
The newest version!
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.application.impl;
import com.intellij.ide.IdeEventQueue;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ModalityStateListener;
import com.intellij.openapi.diagnostic.FrequentEventDetector;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Conditions;
import com.intellij.util.ArrayUtil;
import com.intellij.util.EventDispatcher;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@SuppressWarnings({"SSBasedInspection"})
public class LaterInvocator {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.application.impl.LaterInvocator");
private static final boolean DEBUG = LOG.isDebugEnabled();
private static final Object LOCK = new Object();
private static final IdeEventQueue ourEventQueue = IdeEventQueue.getInstance();
private static final FrequentEventDetector ourFrequentEventDetector = new FrequentEventDetector(1009, 100);
private LaterInvocator() { }
private static class RunnableInfo {
@NotNull private final Runnable runnable;
@NotNull private final ModalityState modalityState;
@NotNull private final Condition> expired;
@NotNull private final ActionCallback callback;
public RunnableInfo(@NotNull Runnable runnable,
@NotNull ModalityState modalityState,
@NotNull Condition> expired,
@NotNull ActionCallback callback) {
this.runnable = runnable;
this.modalityState = modalityState;
this.expired = expired;
this.callback = callback;
}
@Override
@NonNls
public String toString() {
return "[runnable: " + runnable + "; state=" + modalityState + (expired.value(null) ? "; expired" : "")+"] ";
}
}
private static final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy