RiCBoolean RiCOSTimer_init (RiCOSTimer *const me, timeUnit ptime, void (*cbkfunc)(void *), void *params);
me
The RiCOSTimer object to initialize.
pTime
The time between each tick of the timer. In most adapters, the time unit is milliseconds; however, this depends on the specific adapter implementation.
cbkfunc
The tick-timer call-back function used to notify the timer client that a tick occurred.
params
RiCBoolean RiCOSTimer_init(RiCOSTimer * const me,
timeUnit ptime, void (*cbkfunc)(void *), void *params)
{
if (me == NULL) return RiCFALSE;
me->cbkfunc = cbkfunc;
me->param = params;
if (((RiCTimerManager*)params)->realTimeModel) {
/**** VxWorks TickTimer(Real Time) ****/
me->m_Time = ptime;
/* Create a thread that runs the bridge, passing
this as an argument. */
me->ticks = cvrtTmInMStoTicks(me->m_Time);
me->hThread = taskSpawn("timer", PRIORITY_HIGH, 0,
SMALL_STACK, (int (*)())bridge,
(int)(void *)me /*p1*/, 0,0,0,0,0,0,0,0,0 );
return me->hThread != ERROR;
}
else {
/**** IdleTimer (Simulated Time) ****/
me->m_Time = 0; /* Just create context-switch
until the system enters idle mode. */
me->hThread = taskSpawn("timer", PRIORITY_LOW, 0,
SMALL_STACK, (int (*)())bridge, (int)(void*)me,
0,0,0,0,0,0,0,0,0);
return RiCTRUE;
}
}