src/swipl-devel/packages/xpce/man/refmanual/md/timer.md

class timer {#class-timer}

A timer is an object that -when the system is dispatching messages- generates an event at regular intervals. Timers are used to implement simulation, blinking (caret) or to wake-up the user under some (time-based) conditions.

The interval of a timer is specified as a real-number. The actual accuracy depends on the timing capabilities offered by the X-implementation on which PCE has been build.

When executing the message, no arguments are forwarded. @receiver is bound to the timer itself. See ->execute.

NOTE: When multiple objects are animated at a similar speed performance will be much better if a single timer is used. The code below provides a skeleton:

:- pce_global(@stepping, chain).

start_stepping :-
    send(new(@stepper,
             timer(1, message(@stepper, for_all,
                              step))),
         start).

step(Obj) :-
    send(@stepping, append, Obj).

@see class date

Instance variables {#class-timer-instvars}

Send methods {#class-timer-send}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.