From a7d9a3d4760b239da56da66eec400c2ab6fbb2d3 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sun, 20 Jan 2019 20:31:55 +0800 Subject: [PATCH] adjust tls --- include/tls_pointer.h | 2 +- src/memory/wrapper.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/tls_pointer.h b/include/tls_pointer.h index f07d3be..4e263f3 100644 --- a/include/tls_pointer.h +++ b/include/tls_pointer.h @@ -63,7 +63,7 @@ public: T* create(P&&... params) { auto ptr = static_cast(*this); if (ptr == nullptr) { - return (*this) = new T { std::forward

(params)... }; + return (*this) = new T(std::forward

(params)...); } return ptr; } diff --git a/src/memory/wrapper.hpp b/src/memory/wrapper.hpp index bd797f1..44f6b10 100644 --- a/src/memory/wrapper.hpp +++ b/src/memory/wrapper.hpp @@ -14,6 +14,7 @@ #include "def.h" #include "rw_lock.h" +#include "tls_pointer.h" namespace ipc { @@ -42,7 +43,7 @@ public: private: rw_lock lc_; - std::multimap> allocs_; + std::multimap allocs_; struct alloc_t { synchronized* t_; @@ -84,8 +85,8 @@ private: }; auto& alc_info() { - thread_local alloc_t alc { this }; - return alc; + static tls::pointer alc; + return *alc.create(this); } public: