mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
rename concur::queue => `concur::circular_queue
This commit is contained in:
parent
ffb82029d9
commit
9bd8813d46
@ -6,13 +6,13 @@
|
||||
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
#include "libconcur/queue.h"
|
||||
#include "libconcur/circular_queue.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void concur_queue_rtt(benchmark::State &state) {
|
||||
using namespace concur;
|
||||
queue<std::int64_t, relation::single, relation::single> que [2];
|
||||
circular_queue<std::int64_t, relation::single, relation::single> que [2];
|
||||
std::atomic_bool stop = false;
|
||||
auto producer = std::async(std::launch::async, [&stop, &que] {
|
||||
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
||||
@ -35,7 +35,7 @@ void concur_queue_rtt(benchmark::State &state) {
|
||||
|
||||
void concur_queue_1v1(benchmark::State &state) {
|
||||
using namespace concur;
|
||||
queue<std::int64_t, relation::single, relation::single> que;
|
||||
circular_queue<std::int64_t, relation::single, relation::single> que;
|
||||
std::atomic_bool stop = false;
|
||||
auto producer = std::async(std::launch::async, [&stop, &que] {
|
||||
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
|
||||
@ -56,7 +56,7 @@ void concur_queue_1v1(benchmark::State &state) {
|
||||
void concur_queue_NvN(benchmark::State &state) {
|
||||
using namespace concur;
|
||||
|
||||
static queue<std::int64_t, relation::multi, relation::multi> que;
|
||||
static circular_queue<std::int64_t, relation::multi, relation::multi> que;
|
||||
static std::atomic_int run = 0;
|
||||
static std::vector<std::thread> prods;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ LIBCONCUR_NAMESPACE_BEG_
|
||||
|
||||
template <typename T, typename PRelationT = relation::multi
|
||||
, typename CRelationT = relation::multi>
|
||||
class queue
|
||||
class circular_queue
|
||||
: public data_model<T, trans::unicast, PRelationT, CRelationT> {
|
||||
|
||||
using base_t = data_model<T, trans::unicast, PRelationT, CRelationT>;
|
||||
@ -7,14 +7,14 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "libconcur/queue.h"
|
||||
#include "libconcur/circular_queue.h"
|
||||
#include "libimp/log.h"
|
||||
#include "libimp/nameof.h"
|
||||
|
||||
using namespace concur;
|
||||
|
||||
TEST(queue, construct) {
|
||||
using queue_t = queue<int>;
|
||||
TEST(circular_queue, construct) {
|
||||
using queue_t = circular_queue<int>;
|
||||
queue_t q1;
|
||||
EXPECT_TRUE(q1.valid());
|
||||
EXPECT_TRUE(q1.empty());
|
||||
@ -25,7 +25,7 @@ namespace {
|
||||
|
||||
template <typename PR, typename CR>
|
||||
void test_queue_basic() {
|
||||
using queue_t = queue<int, PR, CR>;
|
||||
using queue_t = circular_queue<int, PR, CR>;
|
||||
queue_t q1;
|
||||
EXPECT_TRUE(q1.valid());
|
||||
EXPECT_TRUE(q1.empty());
|
||||
@ -74,7 +74,7 @@ void test_queue_basic() {
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(queue, push_pop) {
|
||||
TEST(circular_queue, push_pop) {
|
||||
test_queue_basic<relation::single, relation::single>();
|
||||
test_queue_basic<relation::single, relation::multi >();
|
||||
test_queue_basic<relation::multi , relation::multi >();
|
||||
@ -91,7 +91,7 @@ void test_queue(std::size_t np, std::size_t nc) {
|
||||
std::uint64_t n;
|
||||
std::uint64_t i;
|
||||
};
|
||||
queue<Data, PR, CR> que;
|
||||
circular_queue<Data, PR, CR> que;
|
||||
|
||||
constexpr static std::uint32_t loop_size = 10'0000;
|
||||
|
||||
@ -139,7 +139,7 @@ void test_queue(std::size_t np, std::size_t nc) {
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(queue, multi_thread) {
|
||||
TEST(circular_queue, multi_thread) {
|
||||
using namespace concur;
|
||||
|
||||
/// \brief 1-1
|
||||
Loading…
x
Reference in New Issue
Block a user