mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
adjust tls
This commit is contained in:
parent
52f447111c
commit
a7d9a3d476
@ -63,7 +63,7 @@ public:
|
||||
T* create(P&&... params) {
|
||||
auto ptr = static_cast<T*>(*this);
|
||||
if (ptr == nullptr) {
|
||||
return (*this) = new T { std::forward<P>(params)... };
|
||||
return (*this) = new T(std::forward<P>(params)...);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -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<std::size_t, alloc_policy*, std::greater<std::size_t>> allocs_;
|
||||
std::multimap<std::size_t, alloc_policy*> 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<alloc_t> alc;
|
||||
return *alc.create(this);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user