Package org.apache.derby.impl.sql.conn
Class GenericStatementContext.CancelQueryTask
java.lang.Object
java.util.TimerTask
org.apache.derby.impl.sql.conn.GenericStatementContext.CancelQueryTask
- All Implemented Interfaces:
Runnable
- Enclosing class:
GenericStatementContext
This is a TimerTask that is responsible for timing out statements,
typically when an application has called Statement.setQueryTimeout().
When the application invokes execute() on a statement object, or
fetches data on a ResultSet, a StatementContext object is allocated
for the duration of the execution in the engine (until control is
returned to the application).
When the StatementContext object is assigned with setInUse(),
a CancelQueryTask is scheduled if a timeout > 0 has been set.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StatementContext
Reference to the StatementContext for the executing statement which might time out. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new task for timing out a statement's execution. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Stops this task and prevents it from cancelling a statement.void
run()
Invoked by a Timer class to cancel an executing statement.Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
Field Details
-
statementContext
Reference to the StatementContext for the executing statement which might time out.
-
-
Constructor Details
-
CancelQueryTask
Initializes a new task for timing out a statement's execution. This does not schedule it for execution, the caller is responsible for calling Timer.schedule() with this object as parameter.
-
-
Method Details
-
run
public void run()Invoked by a Timer class to cancel an executing statement. This method just sets a volatile flag in the associated StatementContext object by calling StatementContext.cancel(); it is the responsibility of the thread executing the statement to check this flag regularly. -
forgetContext
public void forgetContext()Stops this task and prevents it from cancelling a statement. Guarantees that after this method returns, the associated StatementContext object will not be tampered with by this task. Thus, the StatementContext object may safely be allocated to other executing statements.
-