You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/09/12 22:26:36 UTC

[GitHub] [logging-log4cxx] rm5248 commented on a diff in pull request #130: Reduce logging overhead by holding references

rm5248 commented on code in PR #130:
URL: https://github.com/apache/logging-log4cxx/pull/130#discussion_r968985287


##########
src/main/cpp/loggingevent.cpp:
##########
@@ -297,40 +302,62 @@ LoggingEvent::KeySet LoggingEvent::getPropertyKeySet() const
 }
 
 
-const LogString LoggingEvent::getCurrentThreadName()
+const LogString& LoggingEvent::getCurrentThreadName()
 {
-#if APR_HAS_THREADS
-	LOG4CXX_THREAD_LOCAL LogString thread_name;
+#if defined(_WIN32)
+	using ThreadIdType = DWORD;
+	ThreadIdType threadId = GetCurrentThreadId();
+#elif APR_HAS_THREADS
+	using ThreadIdType = apr_os_thread_t;
+	ThreadIdType threadId = apr_os_thread_current();
+#else
+	using ThreadIdType = int;
+	ThreadIdType threadId = 0;
+#endif
 
-	if ( thread_name.size() )
+#if defined(__BORLANDC__)

Review Comment:
   Do you have access to a Borland compiler for this?  I know that Thorsten uses a Borland-derived compiler.
   
   I ask because I was thinking about this the other day, there is already a ThreadLocal class in the sources.  I was figuring that it was obsolete at this point, but maybe it's still useful for Borland compilers?  Maybe make it a templated class(`ThreadLocal<LogString>`)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org