public class StopAfterTimer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
StopAfterTimer.Task
Task class responsible for interruption of the Progress block.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
contextName
Name of the thread for which the timer is set
|
private Control |
control
Session for the current execution context
|
private java.util.concurrent.locks.ReentrantLock |
lock
Lock used for locking cleanup methods
|
private static CentralLogger |
LOG
Logger
|
private StopAfterTimer.Task |
previousTaskBlock
Previous task created for the last block
|
private java.util.concurrent.Semaphore |
semaphore
Semaphore used for avoid race condition between two consecutive interrupts
|
private boolean |
stopConditionRaised
StopCondition was raised by a stop-after timeout
|
private BlockDefinition |
stopedBlock
Blocked stopped by stop-after statement
|
private java.util.Map<BlockDefinition,StopAfterTimer.Task> |
tasks
Stores the interruption task for each block.
|
private java.util.Timer |
timer
Timer responsible of execution a interruption tasks.
|
| Constructor and Description |
|---|
StopAfterTimer(java.lang.String contextName,
Control threadControl)
Creates a managing
StopAfterTimer object for a given
session. |
| Modifier and Type | Method and Description |
|---|---|
StopAfterTimer.Task |
addTimeOut(BlockDefinition blockDefinition,
long timeout)
Adds a new timer task to the
timer queue. |
void |
cleanUp()
Release of the acquired semaphore and resets
stopConditionRaised. |
boolean |
isBlockRegistered(BlockDefinition blockDefinition)
Checks if the block that was given as an parameter is already
present in the timer task
|
boolean |
isStopAfterConditionRaised()
Checks if the a
StopCondition was raised by stop-after timeout. |
boolean |
isStoppedBlock(BlockDefinition blockDefinition)
Checks if the block that was given as an parameter was stopped
by a
StopCondition raised by a stop-after timeout. |
private static final CentralLogger LOG
private java.util.Map<BlockDefinition,StopAfterTimer.Task> tasks
private Control control
private java.util.Timer timer
private StopAfterTimer.Task previousTaskBlock
private BlockDefinition stopedBlock
private boolean stopConditionRaised
private java.lang.String contextName
private java.util.concurrent.Semaphore semaphore
private final java.util.concurrent.locks.ReentrantLock lock
public StopAfterTimer(java.lang.String contextName,
Control threadControl)
StopAfterTimer object for a given
session.session - The session of the current execution context.public boolean isStoppedBlock(BlockDefinition blockDefinition)
StopCondition raised by a stop-after timeout.blockDefinition - Progress block for which we check stop-after timeout.blockDefinition was stopped by an
stop-after timeout, or false otherwise.public boolean isStopAfterConditionRaised()
StopCondition was raised by stop-after timeout.public boolean isBlockRegistered(BlockDefinition blockDefinition)
blockDefinition - Progress block.blockDefinition is already present in
timer task queue, or false otherwise.public void cleanUp()
stopConditionRaised.public StopAfterTimer.Task addTimeOut(BlockDefinition blockDefinition, long timeout)
timer queue.blockDefinition - Block for which the timeout wants to be set.timeout - Number of seconds to be set as a timeout for
blockDefinition.TimeOutException - if timeout is equals to zero.