use thread local instance test=develop

recover_files
peizhilin 6 years ago
parent a6f5ceee74
commit 1cd95d8a0b

@ -23,8 +23,10 @@ template <>
std::string PythonDebugSupport::Format() const {
std::ostringstream sout;
sout << "\nPython Callstacks: \n";
for (auto& line : info) {
sout << line;
if (!info.empty()) {
for (auto &line : info) {
sout << line;
}
}
return sout.str();
}

@ -30,8 +30,8 @@ class DebugSupport {
public:
// Returns the singleton of DebugSupport.
static DebugSupport* GetInstance() {
static std::unique_ptr<DebugSupport> debugSupport_(nullptr);
static std::once_flag init_flag_;
static thread_local std::unique_ptr<DebugSupport> debugSupport_(nullptr);
static thread_local std::once_flag init_flag_;
std::call_once(init_flag_,
[&]() { debugSupport_.reset(new DebugSupport<T>()); });

Loading…
Cancel
Save