org.apache.derby.impl.sql.conn
Class GenericStatementContext.CancelQueryTask

java.lang.Object
  extended by java.util.TimerTask
      extended by 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.


Field Summary
private  StatementContext statementContext
          Reference to the StatementContext for the executing statement which might time out.
 
Constructor Summary
GenericStatementContext.CancelQueryTask(StatementContext ctx)
          Initializes a new task for timing out a statement's execution.
 
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
 

Field Detail

statementContext

private StatementContext statementContext
Reference to the StatementContext for the executing statement which might time out.

Constructor Detail

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.

Method Detail

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.


Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.