org.eclipse.core.tests.harness
Class TestBarrier

java.lang.Object
  extended by org.eclipse.core.tests.harness.TestBarrier

public class TestBarrier
extends java.lang.Object

This class acts as an implementation of a barrier that is appropriate for concurrency test cases that want to fail if a thread fails to achieve a particular state in a reasonable amount of time. This prevents test suites from hanging indefinitely if a concurrency bug is found that would normally result in an indefinite hang.


Field Summary
static int STATUS_BLOCKED
          Convience status constant that can be interpreted differently by each test.
static int STATUS_DONE
          Convience status constant that can be interpreted differently by each test.
static int STATUS_RUNNING
          Convience status constant that can be interpreted differently by each test.
static int STATUS_START
          Convience status constant that can be interpreted differently by each test.
static int STATUS_WAIT_FOR_DONE
          Convience status constant that can be interpreted differently by each test.
static int STATUS_WAIT_FOR_RUN
          Convience status constant that can be interpreted differently by each test.
static int STATUS_WAIT_FOR_START
          Convience status constant that can be interpreted differently by each test.
 
Constructor Summary
TestBarrier()
          Creates a new test barrier suitable for a single thread
TestBarrier(int[] location, int index)
          Creates a new test barrier on the provided status array, suitable for acting as a barrier for multiple threads.
 
Method Summary
 void setStatus(int status)
          Sets this barrier object's status.
 void waitForStatus(int status)
          Blocks the current thread until the receiver's status is set to the given value.
static void waitForStatus(int[] location, int status)
           
static void waitForStatus(int[] location, int index, int status)
          Blocks the current thread until the given variable is set to the given value Times out after a predefined period to avoid hanging tests
 void waitForStatusNoFail(int status)
          The same as other barrier methods, except it will not fail if the job does not start in a "reasonable" time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_BLOCKED

public static final int STATUS_BLOCKED
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_DONE

public static final int STATUS_DONE
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_RUNNING

public static final int STATUS_RUNNING
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_START

public static final int STATUS_START
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_WAIT_FOR_DONE

public static final int STATUS_WAIT_FOR_DONE
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_WAIT_FOR_RUN

public static final int STATUS_WAIT_FOR_RUN
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values

STATUS_WAIT_FOR_START

public static final int STATUS_WAIT_FOR_START
Convience status constant that can be interpreted differently by each test.

See Also:
Constant Field Values
Constructor Detail

TestBarrier

public TestBarrier()
Creates a new test barrier suitable for a single thread


TestBarrier

public TestBarrier(int[] location,
                   int index)
Creates a new test barrier on the provided status array, suitable for acting as a barrier for multiple threads.

Method Detail

waitForStatus

public static void waitForStatus(int[] location,
                                 int status)

waitForStatus

public static void waitForStatus(int[] location,
                                 int index,
                                 int status)
Blocks the current thread until the given variable is set to the given value Times out after a predefined period to avoid hanging tests


setStatus

public void setStatus(int status)
Sets this barrier object's status.


waitForStatus

public void waitForStatus(int status)
Blocks the current thread until the receiver's status is set to the given value. Times out after a predefined period to avoid hanging tests


waitForStatusNoFail

public void waitForStatusNoFail(int status)
The same as other barrier methods, except it will not fail if the job does not start in a "reasonable" time. This is only appropriate for tests that are explicitly very long running.