mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
Use std::ignore to fix unused variable warnings
This commit is contained in:
parent
9f44298350
commit
a401d3f874
@ -3,6 +3,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
#include "benchmark/benchmark.h"
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
@ -18,18 +19,18 @@ void concur_queue_rtt(benchmark::State &state) {
|
|||||||
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
||||||
std::int64_t n {};
|
std::int64_t n {};
|
||||||
while (!que[0].pop(n)) ;
|
while (!que[0].pop(n)) ;
|
||||||
(void)que[1].push(i);
|
std::ignore = que[1].push(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
(void)que[0].push(0);
|
std::ignore = que[0].push(0);
|
||||||
std::int64_t n {};
|
std::int64_t n {};
|
||||||
while (!que[1].pop(n)) ;
|
while (!que[1].pop(n)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop = true;
|
stop = true;
|
||||||
(void)que[0].push(0);
|
std::ignore = que[0].push(0);
|
||||||
producer.wait();
|
producer.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ void concur_queue_1v1(benchmark::State &state) {
|
|||||||
std::atomic_bool stop = false;
|
std::atomic_bool stop = false;
|
||||||
auto producer = std::async(std::launch::async, [&stop, &que] {
|
auto producer = std::async(std::launch::async, [&stop, &que] {
|
||||||
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
||||||
(void)que.push(i);
|
std::ignore = que.push(i);
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -65,7 +66,7 @@ void concur_queue_NvN(benchmark::State &state) {
|
|||||||
prods.resize(state.threads());
|
prods.resize(state.threads());
|
||||||
auto producer = [] {
|
auto producer = [] {
|
||||||
for (std::int64_t i = 0; run.load(std::memory_order_relaxed) > 0; ++i) {
|
for (std::int64_t i = 0; run.load(std::memory_order_relaxed) > 0; ++i) {
|
||||||
(void)que.push(i);
|
std::ignore = que.push(i);
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <tuple>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -46,11 +47,11 @@ private:
|
|||||||
typename decltype(elements)::size_type i = 0;
|
typename decltype(elements)::size_type i = 0;
|
||||||
LIBIMP_TRY {
|
LIBIMP_TRY {
|
||||||
for (; i < elements.size(); ++i) {
|
for (; i < elements.size(); ++i) {
|
||||||
(void)::LIBIMP::construct<element<value_type>>(&elements[i]);
|
std::ignore = ::LIBIMP::construct<element<value_type>>(&elements[i]);
|
||||||
}
|
}
|
||||||
} LIBIMP_CATCH(...) {
|
} LIBIMP_CATCH(...) {
|
||||||
for (decltype(i) k = 0; k < i; ++k) {
|
for (decltype(i) k = 0; k < i; ++k) {
|
||||||
(void)::LIBIMP::destroy<element<value_type>>(&elements[k]);
|
std::ignore = ::LIBIMP::destroy<element<value_type>>(&elements[k]);
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ private:
|
|||||||
|
|
||||||
~data() noexcept {
|
~data() noexcept {
|
||||||
for (auto &elem : this->elements()) {
|
for (auto &elem : this->elements()) {
|
||||||
(void)::LIBIMP::destroy<element<value_type>>(&elem);
|
std::ignore = ::LIBIMP::destroy<element<value_type>>(&elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public:
|
|||||||
~data_model() noexcept {
|
~data_model() noexcept {
|
||||||
if (valid()) {
|
if (valid()) {
|
||||||
auto sz = data_->byte_size();
|
auto sz = data_->byte_size();
|
||||||
(void)::LIBIMP::destroy<data>(data_);
|
std::ignore = ::LIBIMP::destroy<data>(data_);
|
||||||
data_allocator_.deallocate(data_, sz);
|
data_allocator_.deallocate(data_, sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user