Added wxThread::GetCurrentId(), which returns an ID for the current
thread, even if it is not a wxThread. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -159,6 +159,14 @@ Returns the number of system CPUs or -1 if the value is unknown.
|
|||||||
|
|
||||||
\helpref{SetConcurrency}{wxthreadsetconcurrency}
|
\helpref{SetConcurrency}{wxthreadsetconcurrency}
|
||||||
|
|
||||||
|
\membersection{wxThread::GetCurrentId}\label{wxthreadgetcurrentid}
|
||||||
|
|
||||||
|
\func{static unsigned long}{GetCurrentId}{\void}
|
||||||
|
|
||||||
|
Returns the platform specific thread ID of the current thread as a
|
||||||
|
long. This can be used to uniquely identify threads, even if they are
|
||||||
|
not wxThreads.
|
||||||
|
|
||||||
\membersection{wxThread::GetId}\label{wxthreadgetid}
|
\membersection{wxThread::GetId}\label{wxthreadgetid}
|
||||||
|
|
||||||
\constfunc{unsigned long}{GetId}{\void}
|
\constfunc{unsigned long}{GetId}{\void}
|
||||||
|
@@ -286,6 +286,11 @@ public:
|
|||||||
// Returns -1 if unknown, number of CPUs otherwise
|
// Returns -1 if unknown, number of CPUs otherwise
|
||||||
static int GetCPUCount();
|
static int GetCPUCount();
|
||||||
|
|
||||||
|
// Get the platform specific thread ID and return as a long. This
|
||||||
|
// can be used to uniquely identify threads, even if they are not
|
||||||
|
// wxThreads. This is used by wxPython.
|
||||||
|
static unsigned long GetCurrentId();
|
||||||
|
|
||||||
// sets the concurrency level: this is, roughly, the number of threads
|
// sets the concurrency level: this is, roughly, the number of threads
|
||||||
// the system tries to schedule to run in parallel. 0 means the
|
// the system tries to schedule to run in parallel. 0 means the
|
||||||
// default value (usually acceptable, but may not yield the best
|
// default value (usually acceptable, but may not yield the best
|
||||||
|
@@ -647,6 +647,11 @@ int wxThread::GetCPUCount()
|
|||||||
return si.dwNumberOfProcessors;
|
return si.dwNumberOfProcessors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long wxThread::GetCurrentId()
|
||||||
|
{
|
||||||
|
return (unsigned long)::GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
||||||
bool wxThread::SetConcurrency(size_t level)
|
bool wxThread::SetConcurrency(size_t level)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") );
|
wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") );
|
||||||
|
@@ -441,30 +441,14 @@ PyObject* wxPyConstructObject(void* ptr,
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// TODO: This should really be wxThread::GetCurrentId(), and I will do so
|
|
||||||
// after I make a quick 2.3.2.1 release.
|
|
||||||
#ifdef WXP_WITH_THREAD
|
#ifdef WXP_WITH_THREAD
|
||||||
#ifdef __WXGTK__ // does wxGTK always use pthreads?
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#endif
|
|
||||||
inline
|
inline
|
||||||
unsigned long wxPyGetCurrentThreadId() {
|
unsigned long wxPyGetCurrentThreadId() {
|
||||||
#ifdef __WXMSW__
|
return wxThread::GetCurrentId();
|
||||||
return (unsigned long)::GetCurrentThreadId();
|
|
||||||
#endif
|
|
||||||
#ifdef __WXGTK__ // does wxGTK always use pthreads?
|
|
||||||
return (unsigned long)pthread_self();
|
|
||||||
#endif
|
|
||||||
#ifdef __WXMAC__
|
|
||||||
ThreadID current ;
|
|
||||||
MacGetCurrentThread( ¤t ) ;
|
|
||||||
return (unsigned long)current;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
PyThreadState* wxPyGetThreadState() {
|
PyThreadState* wxPyGetThreadState() {
|
||||||
unsigned long ctid = wxPyGetCurrentThreadId();
|
unsigned long ctid = wxPyGetCurrentThreadId();
|
||||||
|
Reference in New Issue
Block a user