mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
补充遗漏的初始化
This commit is contained in:
parent
162011d4b4
commit
2a2b626210
@ -80,12 +80,18 @@ class mutex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pthread_mutex_t const &zero_mem() {
|
||||||
|
static const pthread_mutex_t tmp{};
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mutex() = default;
|
mutex() = default;
|
||||||
~mutex() = default;
|
~mutex() = default;
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
// Avoid exception problems caused by static member initialization order.
|
// Avoid exception problems caused by static member initialization order.
|
||||||
|
zero_mem();
|
||||||
curr_prog::get();
|
curr_prog::get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +104,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool valid() const noexcept {
|
bool valid() const noexcept {
|
||||||
static const char tmp[sizeof(pthread_mutex_t)] {};
|
|
||||||
return (shm_ != nullptr) && (ref_ != nullptr) && (mutex_ != nullptr)
|
return (shm_ != nullptr) && (ref_ != nullptr) && (mutex_ != nullptr)
|
||||||
&& (std::memcmp(tmp, mutex_, sizeof(pthread_mutex_t)) != 0);
|
&& (std::memcmp(&zero_mem(), mutex_, sizeof(pthread_mutex_t)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool open(char const *name) noexcept {
|
bool open(char const *name) noexcept {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user