X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e64313babfa84d2806313c611503e517390b3731..5f254b1f3cf48ea4483aa9a728d1addb0b1f1e23:/src/mac/carbon/thread.cpp diff --git a/src/mac/carbon/thread.cpp b/src/mac/carbon/thread.cpp index 3634a69dde..db758b346f 100644 --- a/src/mac/carbon/thread.cpp +++ b/src/mac/carbon/thread.cpp @@ -38,6 +38,7 @@ #include #include "wx/mac/uma.h" #include "wx/mac/macnotfy.h" +#include #endif #define INFINITE 0xFFFFFFFF @@ -523,16 +524,29 @@ bool wxThread::IsMain() void wxThread::Yield() { +#if TARGET_API_MAC_OSX + CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ; +#endif ::YieldToAnyThread() ; + } void wxThread::Sleep(unsigned long milliseconds) { - clock_t start = clock(); + UnsignedWide start, now; + + Microseconds(&start); + + double mssleep = milliseconds * 1000 ; + double msstart, msnow ; + msstart = (start.hi * 4294967296.0 + start.lo) ; + do { YieldToAnyThread(); - } while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ; + Microseconds(&now); + msnow = (now.hi * 4294967296.0 + now.lo) ; + } while( msnow - msstart < mssleep ); } int wxThread::GetCPUCount()