mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
prepare for circ_queue
This commit is contained in:
parent
21789676e7
commit
fa2c8200bf
@ -15,7 +15,8 @@ INCLUDEPATH += \
|
||||
HEADERS += \
|
||||
../include/export.h \
|
||||
../include/shm.h \
|
||||
../include/circ_elem_array.h
|
||||
../include/circ_elem_array.h \
|
||||
../include/circ_queue.h
|
||||
|
||||
SOURCES += \
|
||||
../src/shm.cpp
|
||||
|
||||
@ -76,7 +76,6 @@ private:
|
||||
|
||||
public:
|
||||
elem_array(void) = default;
|
||||
~elem_array(void) = delete;
|
||||
|
||||
elem_array(const elem_array&) = delete;
|
||||
elem_array& operator=(const elem_array&) = delete;
|
||||
|
||||
15
include/circ_queue.h
Normal file
15
include/circ_queue.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "circ_elem_array.h"
|
||||
|
||||
namespace ipc {
|
||||
namespace circ {
|
||||
|
||||
template <typename T>
|
||||
class queue {
|
||||
private:
|
||||
elem_array<sizeof(T)> elems_;
|
||||
};
|
||||
|
||||
} // namespace circ
|
||||
} // namespace ipc
|
||||
@ -17,6 +17,9 @@ class Unit : public TestSuite {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase(void);
|
||||
void cleanupTestCase(void);
|
||||
|
||||
void test_inst(void);
|
||||
void test_prod_cons_1v1(void);
|
||||
void test_prod_cons_1v3(void);
|
||||
@ -28,6 +31,14 @@ private slots:
|
||||
using cq_t = ipc::circ::elem_array<12>;
|
||||
cq_t* cq__;
|
||||
|
||||
void Unit::initTestCase(void) {
|
||||
cq__ = new cq_t;
|
||||
}
|
||||
|
||||
void Unit::cleanupTestCase(void) {
|
||||
delete cq__;
|
||||
}
|
||||
|
||||
void Unit::test_inst(void) {
|
||||
std::cout << "cq_t::head_size = " << cq_t::head_size << std::endl;
|
||||
std::cout << "cq_t::data_size = " << cq_t::data_size << std::endl;
|
||||
@ -37,7 +48,6 @@ void Unit::test_inst(void) {
|
||||
QCOMPARE(static_cast<std::size_t>(cq_t::data_size) , static_cast<std::size_t>(12));
|
||||
QCOMPARE(sizeof(cq_t), static_cast<std::size_t>(cq_t::block_size + cq_t::head_size));
|
||||
|
||||
cq__ = new cq_t;
|
||||
std::cout << "sizeof(ipc::circ::elem_array<4096>) = " << sizeof(*cq__) << std::endl;
|
||||
|
||||
auto a = cq__->take(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user