Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
use a cancel-specific timer thread for SqlQuery cancelAsynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Sep 7, 2010
1 parent 79a6911 commit 9c2f37c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/com/twitter/querulous/query/SqlQuery.scala
Expand Up @@ -42,7 +42,12 @@ object NullValues {
def apply(typeVal: Int) = nullTypes(typeVal)
}

private object QueryCancellation {
val cancelTimer = new java.util.Timer("Query cancellation timer", true)
}

class SqlQuery(connection: Connection, query: String, params: Any*) extends Query {
import QueryCancellation._

val statement = buildStatement(connection, query, params: _*)

Expand Down Expand Up @@ -78,9 +83,7 @@ class SqlQuery(connection: Connection, query: String, params: Any*) extends Quer
override def run() {
try {
// FIXME make duration configurable
// FIXME use cancel specific timer, so that blocks in
// the global timeout thread do not affect cancel timeouts
Timeout(new com.twitter.xrayspecs.Duration(200)) {
Timeout(cancelTimer, new com.twitter.xrayspecs.Duration(200)) {
try {
// start by trying the nice way
statement.cancel()
Expand Down

0 comments on commit 9c2f37c

Please sign in to comment.