From 35aae588b8f80c500bd41f160f31f9d08b0f7793 Mon Sep 17 00:00:00 2001 From: Peter Sadrozinski Date: Tue, 27 Nov 2012 19:00:00 -0500 Subject: [PATCH] SGThread: Add capability to get current thread id --- simgear/threads/SGThread.cxx | 8 ++++++++ simgear/threads/SGThread.hxx | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/simgear/threads/SGThread.cxx b/simgear/threads/SGThread.cxx index 8e5c3a36..b5761215 100644 --- a/simgear/threads/SGThread.cxx +++ b/simgear/threads/SGThread.cxx @@ -81,6 +81,10 @@ struct SGThread::PrivateData { HANDLE _handle; }; +static long SGThread::current( void ) { + return (long)GetCurrentThreadId(); +} + struct SGMutex::PrivateData { PrivateData() { @@ -227,6 +231,10 @@ struct SGThread::PrivateData { bool _started; }; +long SGThread::current( void ) { + return (long)pthread_self(); +} + struct SGMutex::PrivateData { PrivateData() { diff --git a/simgear/threads/SGThread.hxx b/simgear/threads/SGThread.hxx index 7f3a651a..94d5e405 100644 --- a/simgear/threads/SGThread.hxx +++ b/simgear/threads/SGThread.hxx @@ -50,6 +50,11 @@ public: */ void join(); + /** + *Retreive the current thread id. + */ + static long current( void ); + protected: /** * Destroy a thread object. -- 2.39.5