Commit 3284f575 authored by Davis King's avatar Davis King

Updated to use thread_local instead of old thread_specific_data class.

parent 00910ac1
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <sstream> #include <sstream>
#include <cstring> #include <cstring>
#include "stack_trace.h" #include "stack_trace.h"
#include "threads.h"
#include "stack.h" #include "stack.h"
#include "memory_manager.h" #include "memory_manager.h"
...@@ -31,9 +30,11 @@ namespace dlib ...@@ -31,9 +30,11 @@ namespace dlib
int line_number; int line_number;
}; };
thread_specific_data<stack<stack_tracer_data,memory_manager<char>::kernel_2a>::kernel_1a>& get_dlib_stack_trace_stack() using stack_tracer_stack_type = stack<stack_tracer_data,memory_manager<char>::kernel_2a>::kernel_1a;
stack_tracer_stack_type& get_dlib_stack_trace_stack()
{ {
static thread_specific_data<stack<stack_tracer_data,memory_manager<char>::kernel_2a>::kernel_1a> a; thread_local stack_tracer_stack_type a;
return a; return a;
} }
} }
...@@ -53,7 +54,7 @@ namespace dlib ...@@ -53,7 +54,7 @@ namespace dlib
data.line_number = line_number; data.line_number = line_number;
// pop the info onto the function stack trace // pop the info onto the function stack trace
get_dlib_stack_trace_stack().data().push(data); get_dlib_stack_trace_stack().push(data);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -62,7 +63,7 @@ namespace dlib ...@@ -62,7 +63,7 @@ namespace dlib
~stack_tracer() ~stack_tracer()
{ {
stack_tracer_data temp; stack_tracer_data temp;
get_dlib_stack_trace_stack().data().pop(temp); get_dlib_stack_trace_stack().pop(temp);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -70,10 +71,11 @@ namespace dlib ...@@ -70,10 +71,11 @@ namespace dlib
const std::string get_stack_trace() const std::string get_stack_trace()
{ {
std::ostringstream sout; std::ostringstream sout;
get_dlib_stack_trace_stack().data().reset(); auto& stack = get_dlib_stack_trace_stack();
while (get_dlib_stack_trace_stack().data().move_next()) stack.reset();
while (stack.move_next())
{ {
stack_tracer_data data = get_dlib_stack_trace_stack().data().element(); stack_tracer_data data = stack.element();
sout << data.file_name << ":" << data.line_number << "\n " << data.funct_name << "\n"; sout << data.file_name << ":" << data.line_number << "\n " << data.funct_name << "\n";
} }
return sout.str(); return sout.str();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment