mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VCS: + concurrent tasks test - if all tasks didn't return a result
(cherry picked from commit d7eb74a979394b9a1cd35a69ea1fd2693efeaf87)
This commit is contained in:
-30
@@ -117,36 +117,6 @@ public class DuringChangeListManagerUpdateTestScheme {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TimeoutWaiter {
|
||||
private Getter<Boolean> myControlled;
|
||||
private final static long ourTimeout = 5000;
|
||||
private final Object myLock;
|
||||
|
||||
private TimeoutWaiter() {
|
||||
myLock = new Object();
|
||||
}
|
||||
|
||||
public void setControlled(final Getter<Boolean> controlled) {
|
||||
myControlled = controlled;
|
||||
}
|
||||
|
||||
public void startTimeout() {
|
||||
assert myControlled != null;
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
synchronized (myLock) {
|
||||
while (((System.currentTimeMillis() - start) < ourTimeout) && (! Boolean.TRUE.equals(myControlled.get()))) {
|
||||
try {
|
||||
myLock.wait(300);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkFilesAreInList(final VirtualFile[] files, final String listName, final ChangeListManager manager) {
|
||||
System.out.println("Checking files for list: " + listName);
|
||||
assert manager.findChangeList(listName) != null;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.vcs.changes.pending;
|
||||
|
||||
import com.intellij.openapi.util.Getter;
|
||||
|
||||
public class TimeoutWaiter {
|
||||
private Getter<Boolean> myControlled;
|
||||
private final static long ourTimeout = 5000;
|
||||
private final Object myLock;
|
||||
private boolean myExitedByTimeout;
|
||||
|
||||
public TimeoutWaiter() {
|
||||
myLock = new Object();
|
||||
}
|
||||
|
||||
public void setControlled(final Getter<Boolean> controlled) {
|
||||
myControlled = controlled;
|
||||
}
|
||||
|
||||
public void startTimeout() {
|
||||
assert myControlled != null;
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
synchronized (myLock) {
|
||||
while (true) {
|
||||
try {
|
||||
myLock.wait(300);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
if ((System.currentTimeMillis() - start) >= ourTimeout) {
|
||||
myExitedByTimeout = true;
|
||||
return;
|
||||
}
|
||||
if (Boolean.TRUE.equals(myControlled.get())) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExitedByTimeout() {
|
||||
return myExitedByTimeout;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user