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
025311d5f6
@ -125,8 +125,11 @@ class mutex {
|
|||||||
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
||||||
auto it = info.mutex_handles.find(name);
|
auto it = info.mutex_handles.find(name);
|
||||||
if (it == info.mutex_handles.end()) {
|
if (it == info.mutex_handles.end()) {
|
||||||
it = info.mutex_handles.emplace(name,
|
it = info.mutex_handles
|
||||||
curr_prog::shm_data::init{name}).first;
|
.emplace(
|
||||||
|
std::piecewise_construct, std::forward_as_tuple(name),
|
||||||
|
std::forward_as_tuple(curr_prog::shm_data::init{name}))
|
||||||
|
.first;
|
||||||
}
|
}
|
||||||
mutex_ = &it->second.mtx;
|
mutex_ = &it->second.mtx;
|
||||||
ref_ = &it->second.ref;
|
ref_ = &it->second.ref;
|
||||||
|
|||||||
@ -55,8 +55,12 @@ class mutex {
|
|||||||
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
|
||||||
auto it = info.mutex_handles.find(name);
|
auto it = info.mutex_handles.find(name);
|
||||||
if (it == info.mutex_handles.end()) {
|
if (it == info.mutex_handles.end()) {
|
||||||
it = info.mutex_handles.emplace(name,
|
it = info.mutex_handles
|
||||||
curr_prog::shm_data::init{name, sizeof(pthread_mutex_t)}).first;
|
.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;
|
shm_ = &it->second.shm;
|
||||||
ref_ = &it->second.ref;
|
ref_ = &it->second.ref;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user