use thread local instance test=develop

recover_files
peizhilin 7 years ago
parent a6f5ceee74
commit 1cd95d8a0b

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

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

Loading…
Cancel
Save