init

This method initializes the RiCOSTimer object.

Signature
RiCBoolean RiCOSTimer_init (RiCOSTimer *const me,
   timeUnit ptime, void (*cbkfunc)(void *), 
void *params);
Parameters
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

The parameters to the callback function.

Returns

The method returns RiCTRUE if successful.

Example
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;
   }
}

Feedback