corrected Sleep implementation (as clock() under Mach does only return our own passed time)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
#include "wx/mac/macnotfy.h"
|
#include "wx/mac/macnotfy.h"
|
||||||
|
#include "Timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INFINITE 0xFFFFFFFF
|
#define INFINITE 0xFFFFFFFF
|
||||||
@@ -528,11 +529,20 @@ void wxThread::Yield()
|
|||||||
|
|
||||||
void wxThread::Sleep(unsigned long milliseconds)
|
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
|
do
|
||||||
{
|
{
|
||||||
YieldToAnyThread();
|
YieldToAnyThread();
|
||||||
} while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ;
|
Microseconds(&now);
|
||||||
|
msnow = (now.hi * 4294967296.0 + now.lo) ;
|
||||||
|
} while( msstart - msnow < mssleep );
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxThread::GetCPUCount()
|
int wxThread::GetCPUCount()
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
#include "wx/mac/macnotfy.h"
|
#include "wx/mac/macnotfy.h"
|
||||||
|
#include "Timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INFINITE 0xFFFFFFFF
|
#define INFINITE 0xFFFFFFFF
|
||||||
@@ -528,11 +529,20 @@ void wxThread::Yield()
|
|||||||
|
|
||||||
void wxThread::Sleep(unsigned long milliseconds)
|
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
|
do
|
||||||
{
|
{
|
||||||
YieldToAnyThread();
|
YieldToAnyThread();
|
||||||
} while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ;
|
Microseconds(&now);
|
||||||
|
msnow = (now.hi * 4294967296.0 + now.lo) ;
|
||||||
|
} while( msstart - msnow < mssleep );
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxThread::GetCPUCount()
|
int wxThread::GetCPUCount()
|
||||||
|
Reference in New Issue
Block a user