static OSStatus SFCLooker(void *parameter) { #pragma unused(parameter) OSStatus err; OSStatus junk; err = OTMPXPrepareThisTask(); if (err == noErr) { while ( ! gQuitLooker ) { if ( gLookerEP != NULL ) { (void) OTAtomicAdd32(1, &gLookCounter); junk = OTMPXLook(gLookerEP); if (1) { AbsoluteTime timeToWakeUp; timeToWakeUp = AddDurationToAbsolute(-64, UpTime()); junk = MPDelayUntil(&timeToWakeUp); assert(junk == noErr); // MPLogPrintfSlow("<look>"); } } } } OTMPXUnprepareThisTask(); return err; }
void cFUThread::SleepCurrentThread(unsigned long milliseconds) { // If you trigger this assert, you might be trying to sleep negative time! //assert(milliseconds < 10000, milliseconds = 0); #if defined (FP_APPLE) AbsoluteTime wakeup = AddDurationToAbsolute(milliseconds, UpTime()); MPDelayUntil(&wakeup); #else Sleep(milliseconds); #endif }
static void RcvSleep() { OSStatus junk; AbsoluteTime timeToWakeUp; MPLogPrintf("SFCRcv: Going to sleep for 1 seconds"); timeToWakeUp = AddDurationToAbsolute(1000, UpTime()); junk = MPDelayUntil(&timeToWakeUp); assert(junk == noErr); MPLogPrintf("SFCRcv: Waking up\n"); }
OSStatus safe_delay_until(AbsoluteTime *pWakeUpTime) { if(execution_context() == k_eExecutionContextMPTask) { return(MPDelayUntil(pWakeUpTime)); } else { uint64_t ullWakeUpTime = force_cast<uint64_t>(*pWakeUpTime); while(force_cast<uint64_t>(UpTime()) < ullWakeUpTime) { idle(); } return(noErr); } }
void wxThread::Sleep( unsigned long milliseconds ) { AbsoluteTime wakeup = AddDurationToAbsolute( milliseconds, UpTime() ); MPDelayUntil( &wakeup ); }