TibrvTimer

Class

Declaration

class TibrvTimer : public TibrvEvent
    TibrvTimer();             // Construct empty.
    virtual ~TibrvTimer();    // Destroy and reclaim storage

Purpose

Timer event.

Remarks

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

The destructor calls the destroy method, unless the C object is already destroyed.

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

Activation and Dispatch

The method TibrvTimer::create() creates a C 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 226: 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 and operating system constraints.

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 in TIBCO Rendezvous Concepts.

Method

Description

TibrvTimer::create()

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::getHandle()

TibrvEvent::getType()

TibrvEvent::getQueue()

TibrvEvent::isValid()

TibrvEvent::isListener()

TibrvEvent::isTimer()

TibrvEvent::isIOEvent()

Related Classes

TibrvEvent