提交 1cd95d8a 编写于 作者: P peizhilin

use thread local instance test=develop

上级 a6f5ceee
...@@ -23,9 +23,11 @@ template <> ...@@ -23,9 +23,11 @@ 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()) {
for (auto &line : info) {
sout << line; sout << line;
} }
}
return sout.str(); return sout.str();
} }
......
...@@ -30,8 +30,8 @@ class DebugSupport { ...@@ -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>()); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册