Mac OS 9
Timer.h File Reference

Time Manager interfaces. More...

#include <ConditionalMacros.h>
#include <MacTypes.h>
#include <OSUtils.h>

Go to the source code of this file.

Data Structures

struct  TMTask
 

Macros

#define NewTimerUPP(userRoutine)
 
#define DisposeTimerUPP(userUPP)   DisposeRoutineDescriptor(userUPP)
 
#define InvokeTimerUPP(tmTaskPtr, userUPP)    CALL_ONE_PARAMETER_UPP((userUPP), uppTimerProcInfo, (tmTaskPtr))
 
#define NewTimerProc(userRoutine)   NewTimerUPP(userRoutine)
 
#define CallTimerProc(userRoutine, tmTaskPtr)    InvokeTimerUPP(tmTaskPtr, userRoutine)
 

Typedefs

typedef struct TMTask TMTask
 
typedef TMTaskTMTaskPtr
 

Enumerations

enum  { kTMTaskActive = (1L << 15) }
 
enum  { uppTimerProcInfo = 0x0000B802 }
 

Functions

typedef CALLBACK_API_REGISTER68K (void, TimerProcPtr,(TMTaskPtr tmTaskPtr))
 
typedef REGISTER_UPP_TYPE (TimerProcPtr) TimerUPP
 
void InsTime (QElemPtr tmTaskPtr)
 Install timer task. More...
 
void InsXTime (QElemPtr tmTaskPtr)
 Install extended Time Manager task. More...
 
void PrimeTime (QElemPtr tmTaskPtr, long count)
 Set interval for timer and start it ticking. More...
 
void RmvTime (QElemPtr tmTaskPtr)
 Remove task from Time Manager queue. More...
 
OSErr InstallTimeTask (QElemPtr tmTaskPtr)
 
OSErr InstallXTimeTask (QElemPtr tmTaskPtr)
 
OSErr PrimeTimeTask (QElemPtr tmTaskPtr, long count)
 
OSErr RemoveTimeTask (QElemPtr tmTaskPtr)
 
void Microseconds (UnsignedWide *microTickCount)
 
TimerUPP NewTimerUPP (TimerProcPtr userRoutine)
 
void DisposeTimerUPP (TimerUPP userUPP)
 
void InvokeTimerUPP (TMTaskPtr tmTaskPtr, TimerUPP userUPP)
 

Detailed Description

Time Manager interfaces.

Introduced In: Mac OS 8.5
Avaliable From: Universal Interfaces 3.4.1
Copyright: � 1985-2001 by Apple Computer, Inc., all rights reserved

For bug reports, consult the following page on the World Wide Web:

http://developer.apple.com/bugreporter/

Macro Definition Documentation

◆ NewTimerUPP

#define NewTimerUPP (   userRoutine)
Value:
(TimerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTimerProcInfo, \
GetCurrentArchitecture())
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)

Function Documentation

◆ DisposeTimerUPP()

void DisposeTimerUPP ( TimerUPP  userUPP)

DisposeTimerUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ InstallTimeTask()

OSErr InstallTimeTask ( QElemPtr  tmTaskPtr)

InstallTimeTask()

Non-Carbon CFM: in InterfaceLib 9.1 and later
Carbon Lib: in CarbonLib 1.0.2 and later
Mac OS X: in version 10.0 and later

◆ InstallXTimeTask()

OSErr InstallXTimeTask ( QElemPtr  tmTaskPtr)

InstallXTimeTask()

Non-Carbon CFM: in InterfaceLib 9.1 and later
Carbon Lib: in CarbonLib 1.0.2 and later
Mac OS X: in version 10.0 and later

◆ InsTime()

void InsTime ( QElemPtr  tmTaskPtr)

Install timer task.

Trap macro _InsTime
On entry A0:address of TMTask record
On exit D0:result code
InsTime adds the Time Manager task record specified by tmTaskPtr to the
Time Manager queue. Your application should fill in the tmAddr field of the
task record and should set the remaining fields to 0. The tmTaskPtr parameter
must point to an original Time Manager task record.
With the revised and extended Time Managers, you can set tmAddr to NIL if
you do not want a task to execute when the delay passed to PrimeTime
expires. Also, calling InsTime with the revised Time Manager causes the
high-order bit of the qType field to be reset to 0.
InsTime enqueues a data structure in preparation for a subsequent call to
PrimeTime , which starts the clock ticking on a timer-alarm triggered task.
After the alarm goes off, your task is still in the Time Manager queue, but it
is no longer primed.
Use the InsXTime procedure if you want to take advantage of the drift-free,
fixed-frequency timing services of the extended
Time Manager .
tmTaskPtr is the address of a 12-byte TMTask structure. You must set the
tmAddr field of this structure to point to the code you wish executed
when the alarm is triggered. Other fields are set automatically.
Returns
none
Note
 Time Manager alarms have resolution of 1ms (1/1000th of
a second). You may enqueue any number of these "wakeup" requests. None
takes effect until you call PrimeTime and the specified interval elapses.
The code of the timer task is executed at interrupt time, so it must be
written with the following constraints:
•It must not call Memory Manager functions directly or indirectly .
You cannot call any Toolbox routine that may move or purge
memory.Note: it is OK to call PrimeTime to set up for another alarm.
•It must not depend on handles of unlocked memory blocks to be valid.
•It must preserve the values of all registers except A0-A3 and D0-D3.
•If it accesses application globals, it must be sure that the A5 register
is valid.
The latter requirement is important. At interrupt time, you cannot depend
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ InsXTime()

void InsXTime ( QElemPtr  tmTaskPtr)

Install extended Time Manager task.

Trap macro _InsXTime
On entry A0:address of TMTask record
On exit D0:result code
InsXTime adds the Time Manager task record specified by tmTaskPtr to
the Time Manager queue. The tmTaskPtr parameter must point to an
extended Time Manager task record. Your application must fill in the tmAddr
field of that task. You should set the tmWakeUp and tmReserved fields to 0 the
first time you call InsXTime .
With the extended Time Manager , you can set tmAddr to NIL if you do not
want a task to execute when the delay passed to PrimeTime expires. Also,
InsXTime resets the high-order bit of the qType field to 0.
The PrimeTime procedure schedules the routine specified by the tmAddr
field of tmTaskPtr for execution after the delay specified by the count
parameter has elapsed.
Returns
none
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ InvokeTimerUPP()

void InvokeTimerUPP ( TMTaskPtr  tmTaskPtr,
TimerUPP  userUPP 
)

InvokeTimerUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ Microseconds()

void Microseconds ( UnsignedWide microTickCount)

Microseconds()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ NewTimerUPP()

TimerUPP NewTimerUPP ( TimerProcPtr  userRoutine)

NewTimerUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ PrimeTime()

void PrimeTime ( QElemPtr  tmTaskPtr,
long  count 
)

Set interval for timer and start it ticking.

Trap macro _PrimeTime
On entry A0:address of TMTask record
D0:specified delay time (long)
On exit D0:result code
PrimeTime starts the clock ticking on a timer-alarm triggered task
previously prepared by means of a call to InsTime .
If the count parameter is a positive value, it is interpreted in milliseconds. If
count is a negative value, it is interpreted in negated microseconds.
(Microsecond delays are allowable only in the revised and extended Time
Managers.) The task record specified by tmTaskPtr must already be inserted
into the queue (by a previous call to InsTime or InsXTime ) before your
application calls the PrimeTime procedure. The PrimeTime procedure
returns immediately, and the specified routine is executed after the specified
delay has elapsed. If you call PrimeTime with a time delay of 0, the
procedure runs as soon as interrupts are enabled.
In the revised and extended Time Managers, PrimeTime sets the high-order
bit of the qType field to 1. In addition, any value of the count parameter that
exceeds the maximum millisecond delay is reduced to the maximum. If you
pause an unexpired task (with RmvTime ) and then reinstall it (with
InsXTime ), you can continue the previous delay by calling PrimeTime
with the count parameter set to 0.
tmTaskPtr is the address of a 12-byte TMTask structure previously used in a
call to InsTime .
msCount specifies how long, in milliseconds, to wait before calling your
wakeup routine.
Returns
none
Note
 PrimeTime may be called more than once for any previously
installed Time Manager task (see InsTime ). Secondary calls override
the previously set interval. Thus, you can use this as a "watchdog" timer to
be called before you start some event that is prone to getting locked into a
loop.
PrimeTime does not make any demands on the Memory Manager , so it
can be called from inside your alarm handling routine in order to set a new
interval for that routine.
See InsTime for an example of usage.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ PrimeTimeTask()

OSErr PrimeTimeTask ( QElemPtr  tmTaskPtr,
long  count 
)

PrimeTimeTask()

Non-Carbon CFM: in InterfaceLib 9.1 and later
Carbon Lib: in CarbonLib 1.0.2 and later
Mac OS X: in version 10.0 and later

◆ RemoveTimeTask()

OSErr RemoveTimeTask ( QElemPtr  tmTaskPtr)

RemoveTimeTask()

Non-Carbon CFM: in InterfaceLib 9.1 and later
Carbon Lib: in CarbonLib 1.0.2 and later
Mac OS X: in version 10.0 and later

◆ RmvTime()

void RmvTime ( QElemPtr  tmTaskPtr)

Remove task from Time Manager queue.

Trap macro _RmvTime
On entry A0:address of TMTask record
On exit D0:result code
RmvTime removes a previously installed element from the
Time Manager queue. If the clock was ticking on that timer, it
is stopped and its alarm handling routine will not be called.
The RmvTime procedure removes the Time Manager task record specified
by tmTaskPtr from the Time Manager queue. In both the revised and extended
Time Managers, if the specified task record is active (that is, it has been
activated but the specified time has not yet elapsed), the tmCount field of the
task record returns the amount of time remaining. To provide the greatest
accuracy, the unused time is reported as negated microseconds if that value is
small enough to fit into the tmCount field (even if the delay was originally
specified in milliseconds); otherwise, the unused time is reported in positive
milliseconds. If the time has already expired, tmCount contains 0.
In the revised and extended Time Managers, PrimeTime sets the high-order
bit of the qType field to 0.
tmTaskPtr is the address of a 12-byte TMTask structure previously used in a
call to InsTime .
Returns
none
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later