本文整理汇总了Java中com.intellij.concurrency.JobScheduler类的典型用法代码示例。如果您正苦于以下问题:Java JobScheduler类的具体用法?Java JobScheduler怎么用?Java JobScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobScheduler类属于com.intellij.concurrency包,在下文中一共展示了JobScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancelAndRestartDaemonLater
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress,
@NotNull final Project project) throws ProcessCanceledException {
progress.cancel();
JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
Application application = ApplicationManager.getApplication();
if (!project.isDisposed() && !application.isDisposed() && !application.isUnitTestMode()) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
DaemonCodeAnalyzer.getInstance(project).restart();
}
}, project.getDisposed());
}
}
}, RESTART_DAEMON_RANDOM.nextInt(100), TimeUnit.MILLISECONDS);
throw new ProcessCanceledException();
}
示例2: LocalFileSystemImpl
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
public LocalFileSystemImpl(@NotNull ManagingFS managingFS) {
myManagingFS = managingFS;
myWatcher = new FileWatcher(myManagingFS);
if (myWatcher.isOperational()) {
final int PERIOD = 1000;
Runnable runnable = new Runnable() {
public void run() {
final Application application = ApplicationManager.getApplication();
if (application == null || application.isDisposed()) return;
storeRefreshStatusToFiles();
JobScheduler.getScheduler().schedule(this, PERIOD, TimeUnit.MILLISECONDS);
}
};
JobScheduler.getScheduler().schedule(runnable, PERIOD, TimeUnit.MILLISECONDS);
}
}
示例3: openFatals
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
public void openFatals(@Nullable final LogMessage message) {
if (myDialog != null) return;
if (myOpeningInProgress) return;
myOpeningInProgress = true;
final Runnable task = new Runnable() {
public void run() {
if (isOtherModalWindowActive()) {
if (myDialog == null) {
JobScheduler.getScheduler().schedule(this, (long)300, TimeUnit.MILLISECONDS);
}
return;
}
try {
_openFatals(message);
}
finally {
myOpeningInProgress = false;
}
}
};
task.run();
}
示例4: startBlinker
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private synchronized void startBlinker() {
if (myBlinker != null) {
return;
}
myBlinker = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
boolean enabled = false;
@Override
public void run() {
myIcon.setLayerEnabled(0, enabled);
myIcon.setLayerEnabled(1, false);
myIcon.setLayerEnabled(2, !enabled);
repaint();
enabled = !enabled;
}
}, 1, 1, TimeUnit.SECONDS);
}
示例5: startBackgroundIndicatorPing
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
@NotNull
private ScheduledFuture<?> startBackgroundIndicatorPing() {
return JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
for (ProgressIndicator indicator : nonStandardIndicators) {
try {
indicator.checkCanceled();
}
catch (ProcessCanceledException e) {
indicatorCanceled(indicator);
}
}
}
}, 0, CHECK_CANCELED_DELAY_MILLIS, TimeUnit.MILLISECONDS);
}
示例6: queueChange
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private void queueChange(VirtualFile vf) {
// Since we are working with VirtualFile, they are not necessarily part of the project.
// Check that the file is in the import roots as a proxy for belonging to the project
// (alternatively check if it's under the workspace root?).
if (vf == null || !vf.isValid() || !isInImportRoots(vf)) {
return;
}
queuedFiles.add(vf);
if (!flushIsQueued.compareAndSet(false, true)) {
return;
}
@SuppressWarnings("unused") // go/futurereturn-lsc
Future<?> possiblyIgnoredError =
JobScheduler.getScheduler()
.schedule(
() ->
ApplicationManager.getApplication()
.invokeLater(this::flushQueue, ModalityState.NON_MODAL),
DELAY_TIME_MS,
TimeUnit.MILLISECONDS);
}
示例7: run
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
/** Main run function. */
@Override
public void run() {
if (future != null && !future.isCancelled() && !future.isDone()) {
return;
}
if (leading) {
task.run();
}
future = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
task.run();
if (++attempt >= maxAttempts || trailingTask) {
trailing = false;
if (future != null) {
future.cancel(false);
}
}
}
}, delay, delay, TimeUnit.MILLISECONDS);
}
示例8: openFatals
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
public void openFatals(@Nullable final LogMessage message) {
if (myDialog != null) return;
if (myOpeningInProgress) return;
myOpeningInProgress = true;
final Runnable task = new Runnable() {
@Override
public void run() {
if (isOtherModalWindowActive()) {
if (myDialog == null) {
JobScheduler.getScheduler().schedule(this, (long)300, TimeUnit.MILLISECONDS);
}
return;
}
try {
_openFatals(message);
}
finally {
myOpeningInProgress = false;
}
}
};
task.run();
}
示例9: cancel
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
/**
* @return task if not yet executed
*/
@Nullable
private Runnable cancel() {
synchronized (LOCK) {
if (myFuture != null) {
myFuture.cancel(false);
// TODO Use java.util.concurrent.ScheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true) when on jdk 1.7
((ScheduledThreadPoolExecutor)JobScheduler.getScheduler()).remove((Runnable)myFuture);
myFuture = null;
}
Runnable task = myTask;
myTask = null;
return task;
}
}
示例10: scheduleNextRepaint
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private void scheduleNextRepaint() {
if (myScheduledFuture != null && !myScheduledFuture.isDone()) {
myScheduledFuture.cancel(false);
}
myCalendar.setTimeInMillis(System.currentTimeMillis());
myScheduledFuture = JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
UIUtil.invokeLaterIfNeeded(myRepaintRunnable);
}
}, 60 - myCalendar.get(SECOND), TimeUnit.SECONDS);
}
示例11: MemoryUsagePanel
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
public MemoryUsagePanel() {
setOpaque(false);
setFocusable(false);
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.gc();
updateState();
}
});
setBorder(StatusBarWidget.WidgetBorder.INSTANCE);
updateUI();
new UiNotifyConnector(this, new Activatable() {
private ScheduledFuture<?> myFuture;
@Override
public void showNotify() {
myFuture = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
public void run() {
if (isDisplayable()) {
updateState();
}
}
}, 1, 5, TimeUnit.SECONDS);
}
@Override
public void hideNotify() {
if (myFuture != null) {
myFuture.cancel(true);
myFuture = null;
}
}
});
}
示例12: updateRefreshTimer
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private void updateRefreshTimer() {
cancelRefreshTimer();
if (myState.isRefreshEnabled()) {
myRefresnRunnable = new MyRefreshRunnable(this);
// if "schedule with fixed rate" is used, then after waking up from stand-by mode, events are generated for inactive period
// it does not make sense
myFuture = JobScheduler.getScheduler().scheduleWithFixedDelay(myRefresnRunnable,
myState.getRefreshInterval()*60, myState.getRefreshInterval()*60,
TimeUnit.SECONDS);
}
}
示例13: checkAndOpenPageLater
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private void checkAndOpenPageLater(@NotNull final HostAndPort hostAndPort, final int attemptNumber, int delayMillis) {
JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
checkAndOpenPage(hostAndPort, attemptNumber);
}
}, delayMillis, TimeUnit.MILLISECONDS);
}
示例14: openPageLater
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
private void openPageLater(int millis) {
JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
openPageNow();
}
}, millis, TimeUnit.MILLISECONDS);
}
示例15: checkCreatedProcess
import com.intellij.concurrency.JobScheduler; //导入依赖的package包/类
@Override
protected void checkCreatedProcess(@Nullable final WebBrowser browser,
@Nullable final Project project,
@NotNull final GeneralCommandLine commandLine,
@NotNull final Process process,
@Nullable final Runnable launchTask) {
if (isOpenCommandUsed(commandLine)) {
final Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
try {
if (process.waitFor() == 1) {
showError(ExecUtil.readFirstLine(process.getErrorStream(), null), browser, project, null, launchTask);
}
}
catch (InterruptedException ignored) {
}
}
});
// 10 seconds is enough to start
JobScheduler.getScheduler().schedule(new Runnable() {
@Override
public void run() {
future.cancel(true);
}
}, 10, TimeUnit.SECONDS);
}
}