org.teiid.jdbc
Class EnhancedTimer

java.lang.Object
  extended by org.teiid.jdbc.EnhancedTimer

public class EnhancedTimer
extends Object

Specialized timer that can purge tasks in lg(n) time Uses lock escalation to minimize contention for adding/removing tasks. Will only hold a thread while there are pending tasks.


Nested Class Summary
 class EnhancedTimer.Task
           
 
Constructor Summary
EnhancedTimer(Executor bossExecutor, Executor taskExecutor)
           
EnhancedTimer(String name)
          Constructs a new Timer that directly executes tasks off of a single-thread thread pool.
 
Method Summary
 EnhancedTimer.Task add(Runnable task, long delay)
          Add a delayed task
 int getQueueSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnhancedTimer

public EnhancedTimer(String name)
Constructs a new Timer that directly executes tasks off of a single-thread thread pool.

Parameters:
name -

EnhancedTimer

public EnhancedTimer(Executor bossExecutor,
                     Executor taskExecutor)
Method Detail

add

public EnhancedTimer.Task add(Runnable task,
                              long delay)
Add a delayed task

Parameters:
task -
delay - in ms
Returns:
a cancellable Task

getQueueSize

public int getQueueSize()


Copyright © 2011. All Rights Reserved.