mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
fix: [concur] initialization issues for queue
This commit is contained in:
parent
15db3c6234
commit
e200c49f24
@ -40,7 +40,7 @@ private:
|
|||||||
::LIBIMP::aligned<element<value_type>> elements_start_;
|
::LIBIMP::aligned<element<value_type>> elements_start_;
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
data(U &&model) noexcept
|
data(U &&model)
|
||||||
: header_(std::forward<U>(model)) {
|
: header_(std::forward<U>(model)) {
|
||||||
auto elements = this->elements();
|
auto elements = this->elements();
|
||||||
typename decltype(elements)::size_type i = 0;
|
typename decltype(elements)::size_type i = 0;
|
||||||
@ -52,6 +52,7 @@ private:
|
|||||||
for (decltype(i) k = 0; k < i; ++k) {
|
for (decltype(i) k = 0; k < i; ++k) {
|
||||||
(void)::LIBIMP::destroy<element<value_type>>(&elements[k]);
|
(void)::LIBIMP::destroy<element<value_type>>(&elements[k]);
|
||||||
}
|
}
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,21 +80,23 @@ private:
|
|||||||
if (!data_allocator_) {
|
if (!data_allocator_) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
void *data_ptr = nullptr;
|
||||||
LIBIMP_TRY {
|
LIBIMP_TRY {
|
||||||
auto data_ptr = data_allocator_.alloc(data::size_of(circ_size));
|
data_ptr = data_allocator_.alloc(data::size_of(circ_size));
|
||||||
if (data_ptr == nullptr) {
|
if (data_ptr == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ::LIBIMP::construct<data>(data_ptr, circ_size);
|
return ::LIBIMP::construct<data>(data_ptr, circ_size);
|
||||||
} LIBIMP_CATCH(...) {
|
} LIBIMP_CATCH(...) {
|
||||||
|
data_allocator_.dealloc(data_ptr, data::size_of(circ_size));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::LIBPMR::allocator data_allocator_;
|
::LIBPMR::allocator data_allocator_;
|
||||||
std::atomic<size_type> size_;
|
std::atomic<size_type> size_ {0};
|
||||||
data *data_;
|
data *data_;
|
||||||
typename concur::traits<model_type>::context context_;
|
typename concur::traits<model_type>::context context_ {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
queue(queue const &) = delete;
|
queue(queue const &) = delete;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user