init

This method initializes the RiCOSTask object.

Signature
RiCBoolean RiCOSTask_init (RiCOSTask *const me,
   RiCOSTaskEndCallBack tfunc, void *param, 
   const char *name, const long stackSize);
Parameters
me

The RiCOSTask object to initialize

tfunc

The callback function that ends the current operating system task

param

The parameters to the callback function

name

The name of the task

stackSize

The size of the stack

Returns

The method returns RiCTRUE if successful.

Example
RiCBoolean RiCOSTask_init(RiCOSTask * const me, 
   RiCOSTaskEndCallBack tfunc, void * param, 
   const char * name, const long stackSize)
{
   size_t i, len = 0;
   char* myName = NULL;

   if (me == NULL) {return 0;}

   me->endOSTaskInCleanup = TRUE;
   me->isWrapperThread = 0;

   /* Copy the thread name. */
   if (name != NULL) len = strlen(name);
   /* check for legal name */
   for (i = 0; i < len; i++) {
      if ((isalnum((int)name[i]) == 0) && 
         (name[i] != '_')) {
         len = 0;
         break;
      }
   }
   if (len > 0) {
      myName = malloc(len + 1);
      strcpy(myName, name);
   }
   RiCOSEventFlag_init(&me->m_SuspEventFlag);
   RiCOSEventFlag_reset(&me->m_SuspEventFlag);
   /* Create SUSPENDED thread !!!!!! */
   me->m_ExecFunc = tfunc;
   me->m_ExecParam = param;
   me->hThread = 0;
   me->hThread = taskSpawn(myName, 
      /* name of new task (stored at pStackBase) */
      (int) PRIORITY_NORMAL, /* priority of new task */
      0,      /* task option word */ 
      (int)stackSize, /*size (bytes) of stack needed */
      (int (*)())preExecFunc, /* thread function */
      (int)(void *)me, /* argument to thread function */    
      0,0,0,0,0,0,0,0,0);
   return 1; 
}

Feedback