mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not capture Runnable objects - sometimes the same objects are scheduled from different stacks
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -206,7 +192,7 @@ public class Alarm implements Disposable {
|
||||
_addRequest(request, delayMillis, modalityState);
|
||||
}
|
||||
|
||||
void _addRequest(@Debugger.Capture @NotNull Runnable request, long delayMillis, @Nullable ModalityState modalityState) {
|
||||
void _addRequest(@NotNull Runnable request, long delayMillis, @Nullable ModalityState modalityState) {
|
||||
synchronized (LOCK) {
|
||||
checkDisposed();
|
||||
final Request requestToSchedule = new Request(request, modalityState, delayMillis);
|
||||
@@ -347,6 +333,7 @@ public class Alarm implements Disposable {
|
||||
private Future<?> myFuture; // guarded by LOCK
|
||||
private final long myDelay;
|
||||
|
||||
@Debugger.Capture
|
||||
private Request(@NotNull final Runnable task, @Nullable ModalityState modalityState, long delayMillis) {
|
||||
synchronized (LOCK) {
|
||||
myTask = task;
|
||||
@@ -411,6 +398,7 @@ public class Alarm implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Debugger.Insert
|
||||
private void runSafely(@Nullable Runnable task) {
|
||||
try {
|
||||
if (!myDisposed && task != null) {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.concurrency;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -241,7 +227,7 @@ public class QueueProcessor<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void runSafely(@Debugger.Insert(group = "com.intellij.util.Alarm._addRequest") @NotNull Runnable run) {
|
||||
public static void runSafely(@NotNull Runnable run) {
|
||||
try {
|
||||
run.run();
|
||||
}
|
||||
|
||||
+5
-4
@@ -46,7 +46,8 @@ public class LaterInvocator {
|
||||
@NotNull private final Condition<?> expired;
|
||||
@Nullable private final ActionCallback callback;
|
||||
|
||||
RunnableInfo(@Debugger.Capture @NotNull Runnable runnable,
|
||||
@Debugger.Capture
|
||||
RunnableInfo(@NotNull Runnable runnable,
|
||||
@NotNull ModalityState modalityState,
|
||||
@NotNull Condition<?> expired,
|
||||
@Nullable ActionCallback callback) {
|
||||
@@ -428,7 +429,7 @@ public class LaterInvocator {
|
||||
|
||||
if (lastInfo != null) {
|
||||
try {
|
||||
doRun(lastInfo.runnable);
|
||||
doRun(lastInfo);
|
||||
lastInfo.markDone();
|
||||
}
|
||||
catch (ProcessCanceledException ignored) { }
|
||||
@@ -443,8 +444,8 @@ public class LaterInvocator {
|
||||
}
|
||||
|
||||
// Extracted to have a capture point
|
||||
private static void doRun(@Debugger.Insert Runnable runnable) {
|
||||
runnable.run();
|
||||
private static void doRun(@Debugger.Insert RunnableInfo info) {
|
||||
info.runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user