mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix emplace construction for shm_data. Previous required copy constructor
This commit is contained in:
parent
035d76d5aa
commit
f0e92a7735
@ -125,8 +125,11 @@ class mutex {
|
||||
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
||||
auto it = info.mutex_handles.find(name);
|
||||
if (it == info.mutex_handles.end()) {
|
||||
it = info.mutex_handles.emplace(name,
|
||||
curr_prog::shm_data::init{name}).first;
|
||||
it = info.mutex_handles
|
||||
.emplace(
|
||||
std::piecewise_construct, std::forward_as_tuple(name),
|
||||
std::forward_as_tuple(curr_prog::shm_data::init{name}))
|
||||
.first;
|
||||
}
|
||||
mutex_ = &it->second.mtx;
|
||||
ref_ = &it->second.ref;
|
||||
|
||||
@ -55,8 +55,12 @@ class mutex {
|
||||
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
||||
auto it = info.mutex_handles.find(name);
|
||||
if (it == info.mutex_handles.end()) {
|
||||
it = info.mutex_handles.emplace(name,
|
||||
curr_prog::shm_data::init{name, sizeof(pthread_mutex_t)}).first;
|
||||
it = info.mutex_handles
|
||||
.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(name),
|
||||
std::forward_as_tuple(curr_prog::shm_data::init{
|
||||
name, sizeof(pthread_mutex_t)}))
|
||||
.first;
|
||||
}
|
||||
shm_ = &it->second.shm;
|
||||
ref_ = &it->second.ref;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user