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:
- java.lang.Runnable
- Enclosing class:
- GenericStatementContext
private static class GenericStatementContext.CancelQueryTask
- extends java.util.TimerTask
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.
Method Summary |
void |
forgetContext()
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
statementContext
private StatementContext statementContext
- Reference to the StatementContext for the executing statement
which might time out.
GenericStatementContext.CancelQueryTask
public GenericStatementContext.CancelQueryTask(StatementContext ctx)
- 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.
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.
- Specified by:
run
in interface java.lang.Runnable
- Specified by:
run
in class java.util.TimerTask
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.
Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.