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) {
|
T* create(P&&... params) {
|
||||||
auto ptr = static_cast<T*>(*this);
|
auto ptr = static_cast<T*>(*this);
|
||||||
if (ptr == nullptr) {
|
if (ptr == nullptr) {
|
||||||
return (*this) = new T { std::forward<P>(params)... };
|
return (*this) = new T(std::forward<P>(params)...);
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "rw_lock.h"
|
#include "rw_lock.h"
|
||||||
|
#include "tls_pointer.h"
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
rw_lock lc_;
|
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 {
|
struct alloc_t {
|
||||||
synchronized* t_;
|
synchronized* t_;
|
||||||
@ -84,8 +85,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto& alc_info() {
|
auto& alc_info() {
|
||||||
thread_local alloc_t alc { this };
|
static tls::pointer<alloc_t> alc;
|
||||||
return alc;
|
return *alc.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user