projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added tinkalink2.wav, as a binary file this time
[wxWidgets.git]
/
src
/
mac
/
thread.cpp
diff --git
a/src/mac/thread.cpp
b/src/mac/thread.cpp
index 8c6e856cc6efa3617710388802a01b387e9209df..5e322a719d2eb0b8f820ce62b2499813e1a194cf 100644
(file)
--- a/
src/mac/thread.cpp
+++ b/
src/mac/thread.cpp
@@
-38,6
+38,7
@@
#include <Threads.h>
#include "wx/mac/uma.h"
#include "wx/mac/macnotfy.h"
#include <Threads.h>
#include "wx/mac/uma.h"
#include "wx/mac/macnotfy.h"
+#include <Timer.h>
#endif
#define INFINITE 0xFFFFFFFF
#endif
#define INFINITE 0xFFFFFFFF
@@
-64,6
+65,7
@@
enum wxThreadState
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
+size_t g_numberOfThreads = 0;
// ============================================================================
// MacOS implementation of thread classes
// ============================================================================
// MacOS implementation of thread classes
@@
-527,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
{
YieldToAnyThread();
do
{
YieldToAnyThread();
- } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
+ Microseconds(&now);
+ msnow = (now.hi * 4294967296.0 + now.lo) ;
+ } while( msnow - msstart < mssleep );
}
int wxThread::GetCPUCount()
}
int wxThread::GetCPUCount()
@@
-571,6
+582,7
@@
bool wxThread::SetConcurrency(size_t level)
wxThread::wxThread(wxThreadKind kind)
{
wxThread::wxThread(wxThreadKind kind)
{
+ g_numberOfThreads++;
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
@@
-579,6
+591,17
@@
wxThread::wxThread(wxThreadKind kind)
wxThread::~wxThread()
{
wxThread::~wxThread()
{
+ if (g_numberOfThreads>0)
+ {
+ g_numberOfThreads--;
+ }
+#ifdef __WXDEBUG__
+ else
+ {
+ wxFAIL_MSG(wxT("More threads deleted than created."));
+ }
+#endif
+
s_threads.Remove( (void*) this ) ;
if (m_internal != NULL) {
delete m_internal;
s_threads.Remove( (void*) this ) ;
if (m_internal != NULL) {
delete m_internal;