|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.testing.threadtester.AbstractBreakpoint
public abstract class AbstractBreakpoint
Base class for implementations of Breakpoint. Provides the basic
functionality for pausing and resuming, but does not provide any mechanism
for recognising when a break point has been reached. Concrete subclasses must
provide a mechanism for recognising when a breakpoint has been reached. Upon
reaching a breakpoint, they should call hitBreakpoint().
| Field Summary | |
|---|---|
protected boolean |
blocked
Set to true if the thread breakpoint is curently blocked. |
protected boolean |
enabled
Set to true if this breakpoint is curently enabled. |
protected int |
limit
The number of times this breakpoint can be hit before activating. |
protected int |
numHits
The number of times this breakpoint has been hit. |
protected Thread |
thread
The thread associated with this breakpoint. |
| Constructor Summary | |
|---|---|
protected |
AbstractBreakpoint()
Creates a new breakpoint that is not initially associated with a thread. |
protected |
AbstractBreakpoint(Thread thread)
Creates a new breakpoint associated with the given thread. |
| Method Summary | |
|---|---|
void |
await()
Waits for this breakpoint to be reached. |
void |
disable()
Disables the Breakpoint. |
void |
enable()
Enables the Breakpoint. |
protected void |
finishWaiting()
|
int |
getHits()
Gets the number of times that this Breakpoint has been hit. |
protected int |
getId()
Returns a unique integer specifying this breakpoint. |
int |
getLimit()
Gets the limit. |
Thread |
getThread()
Gets the thread associated with this Breakpoint, if any. |
protected void |
hitBreakpoint()
This method should be invoked by subclasses when the Breakpoint has been hit. |
boolean |
isBlocked()
Returns true if the associated thread is currently blocked at this breakpoint. |
boolean |
isEnabled()
Returns true if this breakpoint is enabled. |
protected void |
reset()
Resets the breakpoint. |
void |
resume()
Tells the blocked thread to continue. |
void |
resume(Breakpoint nextBreak)
Tells the blocked thread to continue, and then wait for the given breakpoint. |
void |
setHandler(BreakpointHandler handler)
Sets a handler for this Breakpoint. |
void |
setLimit(int count)
Sets the limit. |
protected void |
setThreadImpl(Thread newThread)
Sets the thread associated with this breakpoint, and calls reset(). |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected volatile boolean enabled
protected volatile int limit
protected volatile int numHits
protected volatile boolean blocked
protected volatile Thread thread
getThread().
| Constructor Detail |
|---|
protected AbstractBreakpoint(Thread thread)
protected AbstractBreakpoint()
setThreadImpl(Thread) before using
this breakpoint.
| Method Detail |
|---|
protected void reset()
IllegalStateException - if this breakpoint has already been hit.public Thread getThread()
Breakpoint
getThread in interface Breakpointprotected void setThreadImpl(Thread newThread)
reset(). May be used by implementations of ReusableBreakpoint.
Note that the thread cannot be reset if the original thread is blocked at
this breakpoint. (I.e. if the breakpoint has been hit, but resume(com.google.testing.threadtester.Breakpoint)
has not been called.)
public void setHandler(BreakpointHandler handler)
BreakpointBreakpointHandler.handleBreakpoint(com.google.testing.threadtester.Breakpoint) method.
setHandler in interface Breakpointpublic int getHits()
Breakpoint.getLimit(),
Breakpoint.isEnabled()public int getLimit()
BreakpointBreakpoint.setLimit(int).
getLimit in interface Breakpointpublic void setLimit(int count)
BreakpointNote that once a breakpoint has stopped, it is no longer active, and will not stop again.
setLimit in interface Breakpointpublic final boolean isEnabled()
BreakpointBreakpoint.disable(). A
Breakpoint's thread will only stop if the Breakpoint is enabled.
isEnabled in interface Breakpointpublic void disable()
Breakpoint
disable in interface Breakpointpublic void enable()
BreakpointBreakpoint.disable().
enable in interface Breakpointpublic boolean isBlocked()
Breakpoint
isBlocked in interface Breakpoint
public void await()
throws TestTimeoutException
BreakpointIt is the caller's responsibility to ensure that this breakpoint is reachable in the current environment. Waiting for a breakpoint that is not reached will eventually throw a TestTimeoutException.
await in interface BreakpointTestTimeoutException - if this breakpoint is not reached within the
time limit defined by Options.timeout. The thread of the timeout
exception will be set to the thread of this breakpoint, not to the thread
that called await.
public void resume(Breakpoint nextBreak)
throws TestTimeoutException
BreakpointbreakPoint.resume(); nextBreak.await();
resume in interface BreakpointTestTimeoutExceptionpublic void resume()
BreakpointBreakpoint.await() has been successfully called.
resume in interface Breakpointprotected final void finishWaiting()
protected void hitBreakpoint()
resume(com.google.testing.threadtester.Breakpoint) is
or has been called. Note that calling this method will have no effect if
the breakpoint is disabled.
isEnabled()protected int getId()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||