Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::ACS::jbaci::BACITimer Class Reference

Collaboration diagram for alma::ACS::jbaci::BACITimer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BACITimer (ThreadFactory threadFactory)
Object executeAt (Date date, TimerRunnable command)
Object executeAfterDelay (long millisecondsToDelay, TimerRunnable command)
Object executePeriodically (long period, TimerRunnable command, long firstTime)
synchronized Thread getThread ()
synchronized void shutDown ()

Static Public Member Functions

void cancel (Object taskID)

Protected Member Functions

synchronized void clearThread ()
synchronized void restart ()
synchronized TaskNode nextTask ()

Protected Attributes

final Heap heap_ = new Heap(64)
final ThreadFactory threadFactory_
volatile boolean shutdown_ = false
Thread thread_
final RunLoop runLoop_

Detailed Description

BACI timer. Based on EDU.oswego.cs.dl.util.concurrent (it was not approriate for BACI usage). Timer tasks should complete quickly. If a timer task takes excessive time to complete, it "hogs" the timer's task execution thread. This can, in turn, delay the execution of subsequent tasks, which may "bunch up" and execute in rapid succession when (and if) the offending task finally completes.
See also:
EDU.oswego.cs.dl.util.concurrent
Author:
Matej Sekoranja
Version:
$id$


Constructor & Destructor Documentation

alma::ACS::jbaci::BACITimer::BACITimer ThreadFactory  threadFactory  )  [inline]
 

Constructor.

Parameters:
threadFactory thread factory to be used to create thread, if null no factory is being used


Member Function Documentation

void alma::ACS::jbaci::BACITimer::cancel Object  taskID  )  [inline, static]
 

Cancel a scheduled task that has not yet been run. The task will be cancelled upon the next opportunity to run it. This has no effect if this is a one-shot task that has already executed. Also, if an execution is in progress, it will complete normally. (It may however be interrupted via getThread().interrupt()). But if it is a periodic task, future iterations are cancelled.

Parameters:
taskID -- a task reference returned by one of the execute commands
Exceptions:
ClassCastException if the taskID argument is not of the type returned by an execute command.

synchronized void alma::ACS::jbaci::BACITimer::clearThread  )  [inline, protected]
 

set thread_ to null to indicate termination *

Object alma::ACS::jbaci::BACITimer::executeAfterDelay long  millisecondsToDelay,
TimerRunnable  command
[inline]
 

Excecute the given command after waiting for the given delay.

Parameters:
millisecondsToDelay -- the number of milliseconds from now to run the command.
command -- the command to run after the delay.
Returns:
taskID -- an opaque reference that can be used to cancel execution request

Object alma::ACS::jbaci::BACITimer::executeAt Date  date,
TimerRunnable  command
[inline]
 

Execute the given command at the given time.

Parameters:
date -- the absolute time to run the command, expressed as a java.util.Date.
command -- the command to run at the given time.
Returns:
taskID -- an opaque reference that can be used to cancel execution request

Object alma::ACS::jbaci::BACITimer::executePeriodically long  period,
TimerRunnable  command,
long  firstTime
[inline]
 

Execute the given command every period milliseconds AT FIXED RATE. If startNow is true, execution begins immediately, otherwise, it begins after the first period delay.

Parameters:
period -- the period, in milliseconds. Periods are measured from start-of-task to the next start-of-task. It is generally a bad idea to use a period that is shorter than the expected task duration.
command -- the command to run at each cycle
firstTime -- time when task should start with execution, 0 means immediately.
Exceptions:
IllegalArgumentException if period less than or equal to zero.
Returns:
taskID -- an opaque reference that can be used to cancel execution request

synchronized Thread alma::ACS::jbaci::BACITimer::getThread  )  [inline]
 

Return the thread being used to process commands, or null if there is no such thread. You can use this to invoke any special methods on the thread, for example, to interrupt it.

synchronized TaskNode alma::ACS::jbaci::BACITimer::nextTask  )  [inline, protected]
 

Return the next task to execute, or null if thread is interrupted *

synchronized void alma::ACS::jbaci::BACITimer::restart  )  [inline, protected]
 

Start (or restart) a thread to process commands, or wake up an existing thread if one is already running. This method can be invoked if the background thread crashed due to an unrecoverable exception in an executed command.

synchronized void alma::ACS::jbaci::BACITimer::shutDown  )  [inline]
 

Cancel all tasks and interrupt the background thread executing the current task, if any. A new background thread will be started if new execution requests are encountered. If the currently executing task does not repsond to interrupts, the current thread may persist, even if a new thread is started via restart().


Member Data Documentation

final Heap alma::ACS::jbaci::BACITimer::heap_ = new Heap(64) [protected]
 

tasks are maintained in a standard priority queue *

final RunLoop alma::ACS::jbaci::BACITimer::runLoop_ [protected]
 

volatile boolean alma::ACS::jbaci::BACITimer::shutdown_ = false [protected]
 

shutdown status flag *

Thread alma::ACS::jbaci::BACITimer::thread_ [protected]
 

The thread used to process commands *

final ThreadFactory alma::ACS::jbaci::BACITimer::threadFactory_ [protected]
 

thread factory, can be null *


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:27 2009 for ACS Java API by doxygen 1.3.8