From 64da99feb9146eb734b8261306995067d49d155b Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 14 Jul 2010 15:45:19 +0400 Subject: [PATCH] VCS: + concurrent tasks test - if all tasks didn't return a result (cherry picked from commit d7eb74a979394b9a1cd35a69ea1fd2693efeaf87) --- ...ringChangeListManagerUpdateTestScheme.java | 30 ---------- .../vcs/changes/pending/TimeoutWaiter.java | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/TimeoutWaiter.java diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java index 5f6dae46b7a7..c951995dfd5d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java @@ -117,36 +117,6 @@ public class DuringChangeListManagerUpdateTestScheme { } } - private static class TimeoutWaiter { - private Getter myControlled; - private final static long ourTimeout = 5000; - private final Object myLock; - - private TimeoutWaiter() { - myLock = new Object(); - } - - public void setControlled(final Getter 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; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/TimeoutWaiter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/TimeoutWaiter.java new file mode 100644 index 000000000000..4e397b708ff1 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/TimeoutWaiter.java @@ -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 myControlled; + private final static long ourTimeout = 5000; + private final Object myLock; + private boolean myExitedByTimeout; + + public TimeoutWaiter() { + myLock = new Object(); + } + + public void setControlled(final Getter 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; + } +}