From cebc4a101e7a1ab85b3850de9ff791505240cab5 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 18 Feb 2015 15:37:45 +0000 Subject: [PATCH] Remove use of boost thread local storage from debug Change-Id: I68cde616b373717346d79de130af1f2f1c2ba762 --- build/tizen/dali-core/Makefile.am | 3 ++- dali/integration-api/debug.cpp | 44 +++++---------------------------------- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/build/tizen/dali-core/Makefile.am b/build/tizen/dali-core/Makefile.am index f7a73e3..2550e5e 100644 --- a/build/tizen/dali-core/Makefile.am +++ b/build/tizen/dali-core/Makefile.am @@ -72,7 +72,8 @@ libdali_core_la_CXXFLAGS = -DDALI_COMPILATION \ $(DALI_CFLAGS) libdali_core_la_LIBADD = $(DALI_LDFLAGS) \ - -lboost_thread + -lboost_thread \ + -lboost_system # Create an empty shaderbin dir install-data-local: diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index 9a081ce..fa0e9c3 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -25,10 +25,6 @@ #include #include -#ifndef EMSCRIPTEN -# include -#endif - // INTERNAL INCLUDES #include #include @@ -85,28 +81,7 @@ namespace Integration namespace Log { -typedef LogFunction* LogFunctionPtr; ///< LogFunction pointer - -/** - * This stores a pointer to a log function in thread local storage. - * The data has to be allocated from the heap because - * it will automatically be deleted when the thread terminates - */ -struct ThreadLocalLogging -{ - ThreadLocalLogging(LogFunction func) - :function(func) - { - } - - LogFunction function; -}; - -#ifndef EMSCRIPTEN // single threaded -boost::thread_specific_ptr threadLocal; -#else -std::auto_ptr threadLocal; -#endif +__thread LogFunction gthreadLocalLogFunction = NULL; /* Forward declarations */ std::string FormatToString(const char *format, ...); @@ -114,14 +89,7 @@ std::string ArgListToString(const char *format, va_list args); void LogMessage(DebugPriority priority, const char* format, ...) { - ThreadLocalLogging* threadLogging = threadLocal.get(); - // see if there is a log function for this thread - if (!threadLogging) - { - return; - } - const LogFunction& logfunction = threadLogging->function; - if (!logfunction) + if ( !gthreadLocalLogFunction ) { return; } @@ -131,7 +99,7 @@ void LogMessage(DebugPriority priority, const char* format, ...) std::string message = ArgListToString(format, arg); va_end(arg); - logfunction(priority,message); + gthreadLocalLogFunction(priority,message); } void InstallLogFunction(const LogFunction& logFunction) @@ -139,14 +107,12 @@ void InstallLogFunction(const LogFunction& logFunction) // TLS stores a pointer to an object. // It needs to be allocated on the heap, because TLS will destroy it when the thread exits. - ThreadLocalLogging* logStruct = new ThreadLocalLogging(logFunction); - - threadLocal.reset(logStruct); + gthreadLocalLogFunction = logFunction; } void UninstallLogFunction() { - threadLocal.reset(); + gthreadLocalLogFunction = NULL; } #ifdef DEBUG_ENABLED -- 2.7.4