You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2017/06/26 13:34:24 UTC

[trafficserver] branch master updated: Better initialization in Thread.cc.

This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new a72b145  Better initialization in Thread.cc.
a72b145 is described below

commit a72b1459bff48ab10da71d21d854177b27d4bd8f
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Fri Jun 23 09:29:10 2017 -0500

    Better initialization in Thread.cc.
---
 iocore/eventsystem/Thread.cc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/iocore/eventsystem/Thread.cc b/iocore/eventsystem/Thread.cc
index d0303f8..4eff26b 100644
--- a/iocore/eventsystem/Thread.cc
+++ b/iocore/eventsystem/Thread.cc
@@ -35,10 +35,17 @@
 // Common Interface impl                     //
 ///////////////////////////////////////////////
 
-static ink_thread_key init_thread_key();
+ink_hrtime Thread::cur_time = ink_get_hrtime_internal();
+inkcoreapi ink_thread_key Thread::thread_data_key;
 
-ink_hrtime Thread::cur_time                       = ink_get_hrtime_internal();
-inkcoreapi ink_thread_key Thread::thread_data_key = init_thread_key();
+namespace
+{
+static bool initialized = ([]() -> bool {
+  // File scope initialization goes here.
+  ink_thread_key_create(&Thread::thread_data_key, nullptr);
+  return true;
+})();
+}
 
 Thread::Thread()
 {
@@ -54,13 +61,6 @@ Thread::~Thread()
   MUTEX_UNTAKE_LOCK(mutex, (EThread *)this);
 }
 
-ink_thread_key
-init_thread_key()
-{
-  ink_thread_key_create(&Thread::thread_data_key, nullptr);
-  return Thread::thread_data_key;
-}
-
 ///////////////////////////////////////////////
 // Unix & non-NT Interface impl              //
 ///////////////////////////////////////////////

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].