| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

The Timer Agent - SMTTIME

Generates timing events. You can request one timing event after a specific delay, or repeated timing events at regular intervals. The timer is accurate to 1/100th of a second. You specify delays as a number of days and a number of centiseconds.

To use SMTTIME, call smttime init(). This creates a single unnamed thread automatically the first time it is called, and has no effect thereafter. You can then send messages to this thread. It supports these methods:

Example of initialising SMTTIME:

/*  Static data                                                 */
static QID
    timeq;                      /*  Timer agent event queue     */

    /*  In agent initialisation code                            */
    THREAD  *thread;            /*  Handle to various threads   */

    method declare (agent, "TIME_ALARM", alarm_event, 0);
    method declare (agent, "TIME_ERROR", error_event, 0);

    /*  Ensure that timer agent is running, else start it       */
    smttime init ();
    if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
        timeq = thread-> queue-> qid;
    else
        return (-1);

The ALARM Method

Sends a single alarm event after some specified delay. Build the event body using exdr_write() and the message definition SMT_TIME_ALARM. The event body consists of these fields (see exdr_write() for the field types):

SMTTIME replies to an ALARM event with one of these events:

The ALARM method implicitly does a FLUSH before proceeding.

The WAKEUP Method

Sends a single alarm event at some specified day and time. Build the event body using exdr_write() and the message definition SMT_TIME_ALARM. The event body consists of these fields (see exdr_write() for the field types):

SMTTIME replies to a WAKEUP event with one of these events:

The WAKEUP method implicitly does a FLUSH before proceeding.

The CLOCK Method

Sends a repeated alarm event after some specified delay, for ever, or a specific number of times. Build the event body using exdr_write() and the message definition SMT_TIME_CLOCK. The event body consists of these fields (see exdr_write() for the field types):

SMTTIME replies to a CLOCK event with one of these events:

The CLOCK method implicitly does a FLUSH before proceeding.

The FLUSH Method

Removes any requests sent by a particular client thread. Use this to cancel a CLOCK method, or an unexpired ALARM or WAKEUP request. You do not need to provide an event body, but you must specify your thread's QID correctly when you use event_send(). SMTTIME does not reply to a FLUSH method.

Example Of Use

The SMTTST1 test agent shows an example of using the timer agent.

SMTTIME Implementation

The hypertext view of SMTTIME's dialog and source code may help to understand how SMTTIME works.


| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation