Open topic with navigation

TIBCO Rendezvous® 8.7.0

# TibrvTimer

Class

## Declaration

    class com.tibco.tibrv.TibrvTimer
      extends TibrvEvent

## Purpose

Timer event.

## Remarks

All timers are repeating timers. To simulate a once-only timer, code the callback method to destroy the timer.

Programs must destroy instances of this class. Rendezvous software keeps internal references to these objects, so the Java garbage collector does not delete them automatically.

Destroying the queue of a timer automatically destroys the timer as well.

## Activation and Dispatch

The constructor creates a timer event object, and activates the timer event—that is, it requests notification from the operating system when the timer’s interval elapses. When the interval elapses, Rendezvous software places the event object on its event queue. Dispatch removes the event object from the queue, and runs the callback method to process the timer event. When the callback method begins, Rendezvous software automatically reactivates the event, using the same interval. On dispatch Rendezvous software also determines whether the next interval has already elapsed, and requeues the timer event if appropriate. (To stop the cycle, destroy the event object; see TibrvEvent.destroy().)

Notice that time waiting in the event queue until dispatch can increase the effective interval of the timer. It is the programmer’s responsibility to ensure timely dispatch of events.

Timer Activation and Dispatch illustrates a sequence of timer intervals. The number of elapsed timer intervals directly determines the number of event callbacks.

At any moment the timer object appears on the event queue at most once—not several times as multiple copies. Nonetheless, Rendezvous software arranges for the appropriate number of timer event callbacks based the number of intervals that have elapsed since the timer became active or reset its interval.

Destroying or invalidating the timer object immediately halts the sequence of timer events. The timer object ceases to queue new events, and an event already in the queue does not result in a callback. (However, callback methods that are already running in other threads continue to completion.)

Resetting the timer interval immediately interrupts the sequence of timer events and begins a new sequence, counting the new interval from that moment. The reset operation is equivalent to destroying the timer and creating a new object in its place.

Figure 246: Timer Activation and Dispatch

## Timer Granularity

Express the timer interval (in seconds) as a 64-bit floating point number. This representation allows microsecond granularity for intervals for over 100 years. The actual granularity of intervals depends on hardware, Java and operating system constraints. Most releases of the JVM limit timer granularity to 10 milliseconds.

## Zero as Interval

Many programmers traditionally implement user events as timers with interval zero. Instead, we recommend implementing user events as messages on the intra-process transport. For more information, see Intra-Process Transport and User Events on page 89 in TIBCO Rendezvous Concepts.

Method | Description
TibrvTimer() | Start a timer.
TibrvTimer.getInterval() | Extract the interval from a timer event object.
TibrvTimer.resetInterval() | Reset the interval of a timer event object.

Inherited Methods
`TibrvEvent.destroy()` `TibrvEvent.getClosure()` TibrvEvent.getQueue() TibrvEvent.isValid()
`java.lang.Object.equals` `java.lang.Object.getClass` `java.lang.Object.hashCode` `java.lang.Object.notify` `java.lang.Object.notifyAll` `java.lang.Object.toString` (override) `java.lang.Object.wait`

## Descendants

TibrvEvent

Subtopics

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Rendezvous®

Copyright © 1997-2023. Cloud Software Group, Inc. All Rights Reserved.