Blueprint Help Send comments on this topic.
ClpSleep

Glossary Item Box

Description

When a CLIP thread needs to do nothing for a given time, or wants to run intermittently but doesn't want to waste system resources by running in a small loop, it can call a sleep function. The sleep function will suspend the thread for the specified time. During this time the thread will consume no system resources. When the thread is woken it is added to the system 'executable' stack, where it will be rescheduled along with all of the other system threads.

Although the sleep time is specified in milliseconds, the accuracy of the wake will depend on the underlying operating system and the threads priority.

Eg. In a Microsoft Windows environment there is an inherent system time-slice of 40ms. Thus if a 1ms sleep where to be requested, the operating system would wake the thread anything between 1 and 40ms later depending on the system load and other running tasks.

Generation

The ClpSleep function will suspend the thread for the specified time

Uns ClpSleep( Uns sleepfor );

sleepfor

Time for the process to sleep in milliseconds.

Return

This function will return TRUE if successful, or FALSE otherwise.

Examples

Uns AppCct_NonCriticalThrdElem::Process()
{
   Uns success = TRUE;
   Uns elemNum = this->ElemNum();

   while ( success )
   {
      ClpDiag( "NonCritical Thread %d: Processing\n", elemNum );

      success = DoNonCriticalStuff();

      if ( success )
         ClpSleep( 2500 );
   }

   ClpDiag( "NonCritical Thread %d: Exiting\n", elemNum );

   return success;
}