mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Core: Thread threadid support
git-svn-id: svn://ultimatepp.org/upp/trunk@2993 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6ff25863e0
commit
edd2c87024
2 changed files with 53 additions and 44 deletions
|
|
@ -44,11 +44,11 @@ class Callback;
|
|||
class Thread : NoCopy {
|
||||
#ifdef PLATFORM_WIN32
|
||||
HANDLE handle;
|
||||
DWORD thread_id;
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
pthread_t handle;
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool Run(Callback cb);
|
||||
|
||||
|
|
@ -56,17 +56,22 @@ public:
|
|||
int Wait();
|
||||
|
||||
bool IsOpen() const { return handle; }
|
||||
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
typedef HANDLE Handle;
|
||||
typedef DWORD Id;
|
||||
|
||||
Id GetId() const { return thread_id; }
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
typedef pthread_t Handle;
|
||||
typedef pthread_t Id;
|
||||
|
||||
Id GetId() const { return handle; }
|
||||
#endif
|
||||
|
||||
Handle GetHandle() const { return handle; }
|
||||
|
||||
Handle GetHandle() const { return handle; }
|
||||
|
||||
void Priority(int percent); // 0 = lowest, 100 = normal
|
||||
|
||||
static void Start(Callback cb);
|
||||
|
|
@ -78,12 +83,13 @@ public:
|
|||
static int GetCount();
|
||||
static void ShutdownThreads();
|
||||
static bool IsShutdownThreads();
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
static Handle GetCurrentHandle() { return GetCurrentThread(); }
|
||||
static Handle GetCurrentHandle() { return GetCurrentThread(); }
|
||||
static inline Id GetCurrentId() { return ::GetCurrentThreadId(); };
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
static Handle GetCurrentHandle() { return pthread_self(); }
|
||||
static Handle GetCurrentHandle() { return pthread_self(); }
|
||||
static inline Id GetCurrentId() { return pthread_self(); };
|
||||
#endif
|
||||
|
||||
Thread();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue