Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 59931b9

Browse files
committed
Use std::this_thread::get_id() instead of log4tango::threading::thread_id()
Following a suggestion from @mliszcz Removed log4tango::threading::thread_id() no longer used log4tango::LoggingEvent::thread_id is now an std::thread::id instead of a long
1 parent 918e645 commit 59931b9

File tree

6 files changed

+3
-31
lines changed

6 files changed

+3
-31
lines changed

log4tango/include/log4tango/LoggingEvent.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <log4tango/Portability.hh>
3232
#include <string>
33+
#include <thread>
3334

3435
#include <log4tango/Level.hh>
3536
#include <log4tango/TimeStamp.hh>
@@ -92,7 +93,7 @@ public:
9293
std::string thread_name;
9394

9495
/** id of thread in which this logging event was generated */
95-
long thread_id;
96+
std::thread::id thread_id;
9697

9798
/** The number of seconds elapsed since the epoch
9899
(1/1/1970 00:00:00 UTC) until logging event was created. */

log4tango/include/log4tango/threading/MSThreads.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ namespace threading {
6666

6767
std::string get_thread_id (void);
6868

69-
long thread_id (void);
70-
7169
//-----------------------------------------------------------------------------
7270
// Class : MSMutex
7371
//-----------------------------------------------------------------------------

log4tango/include/log4tango/threading/PThreads.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ namespace threading {
4040

4141
std::string get_thread_id (void);
4242

43-
long thread_id (void);
44-
4543
//-----------------------------------------------------------------------------
4644
// Class : Mutex
4745
//-----------------------------------------------------------------------------

log4tango/src/LoggingEvent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ LoggingEvent::LoggingEvent (const std::string& _logger_name,
4646
level(_level)
4747
{
4848
//-- thread_name = threading::get_thread_id();
49-
thread_id = threading::thread_id();
49+
thread_id = std::this_thread::get_id();
5050
}
5151

5252
LoggingEvent::LoggingEvent (const LoggingEvent& _src)

log4tango/src/MSThreads.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ std::string get_thread_id (void)
4343
return std::string(buffer);
4444
}
4545

46-
//+----------------------------------------------------------------------------
47-
// method : thread_id
48-
//-----------------------------------------------------------------------------
49-
long thread_id (void)
50-
{
51-
return static_cast<long>(::GetCurrentThreadId());
52-
}
53-
5446
} // namespace threading
5547

5648
} // namespace log4tango

log4tango/src/PThreads.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ std::string get_thread_id (void)
4848
return oss.str();
4949
}
5050

51-
//+----------------------------------------------------------------------------
52-
// method : thread_id
53-
//-----------------------------------------------------------------------------
54-
long thread_id (void)
55-
{
56-
#ifndef __darwin__
57-
#if (!defined (__FreeBSD__) && !defined( __OpenBSD__) )
58-
return static_cast<long>(::pthread_self());
59-
#else
60-
return reinterpret_cast<long>(::pthread_self());
61-
#endif
62-
#else
63-
pthread_t thread = ::pthread_self();
64-
return thread->__sig;
65-
#endif
66-
}
67-
6851
//+----------------------------------------------------------------------------
6952
// method : RecursiveMutex::RecursiveMutex
7053
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)