mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix bugs of circ_queue
This commit is contained in:
parent
c9ce4b466a
commit
7d91b187fe
@ -36,8 +36,6 @@ public:
|
||||
swap(rhs);
|
||||
}
|
||||
|
||||
~queue(void) { detach(); }
|
||||
|
||||
void swap(queue& rhs) {
|
||||
std::swap(elems_ , rhs.elems_ );
|
||||
std::swap(cursor_, rhs.cursor_);
|
||||
@ -96,7 +94,7 @@ public:
|
||||
while (cursor_ == elems_->cursor()) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
auto item_ptr = static_cast<T*>(elems_->take(cursor_));
|
||||
auto item_ptr = static_cast<T*>(elems_->take(cursor_++));
|
||||
T item = *item_ptr;
|
||||
elems_->put(item_ptr);
|
||||
return item;
|
||||
|
||||
@ -88,7 +88,9 @@ struct test_confirm {
|
||||
int lcount_;
|
||||
|
||||
test_confirm(int M) {
|
||||
list_ = new std::remove_reference_t<decltype(*list_)>[lcount_ = M];
|
||||
list_ = new std::remove_reference_t<decltype(*list_)>[
|
||||
static_cast<std::size_t>(lcount_ = M)
|
||||
];
|
||||
}
|
||||
|
||||
~test_confirm(void) {
|
||||
@ -315,7 +317,7 @@ void Unit::test_queue(void) {
|
||||
queue.attch(cq);
|
||||
QVERIFY(queue.detach() != nullptr);
|
||||
|
||||
test_prod_cons<1, 1>((ipc::circ::queue<msg_t>*)nullptr);
|
||||
test_prod_cons<1, 3>((ipc::circ::queue<msg_t>*)nullptr);
|
||||
}
|
||||
|
||||
} // internal-linkage
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user