int ct_wait_on_timeout( unsigned long interval );
However, if the thread returns without emptying its message queue, the call to ct_wait_on_timeout() will have no effect. The scheduler will enqueue the thread for execution at the highest priority.
If the thread is still asleep when the specified interval has elapsed, the scheduler will awaken it, enqueuing it for execution at the highest priority. If the thread is awakened by a message or an enqueue before the timeout expires, the timeout is cancelled.
The timing starts when the thread calls ct_wait_on_timeout(). However the waiting doesn't start until the thread returns control to the scheduler.
If a thread calls ct_wait_on_timeout() more than once before returning control to the scheduler, the last such call will overrule the earlier calls.
The timeout interval is a minimum time, not a maximum time. In other words, the thread will sleep at least as long as the specified interval (assuming it is not awakened first by some other event), but it may well sleep longer, depending on what the application is doing when the timeout expires. This kind of imprecision is typical for software timers, and is unavoidable for Cheap Threads in particular. The scheduler doesn't have a chance to awaken a sleeping thread until it regains control from whatever other thread is running.
The ct_wait_on_timeout function is available only if you compile Cheap Threads with the CT_TIMEOUT macro defined.