mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
ipc::circ::relat => ipc::relat; ipc::circ::trans => ipc::trans
This commit is contained in:
parent
cfd175dbdc
commit
612a59ae31
@ -41,16 +41,6 @@ elem_t<S>* elem_of(void* ptr) noexcept {
|
|||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
enum class relat { // multiplicity of the relationship
|
|
||||||
single,
|
|
||||||
multi
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class trans { // transmission
|
|
||||||
unicast,
|
|
||||||
broadcast
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
/// producer-consumer policies
|
/// producer-consumer policies
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -17,9 +17,7 @@ namespace ipc {
|
|||||||
namespace circ {
|
namespace circ {
|
||||||
|
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename Policy = circ::prod_cons<circ::relat::single,
|
typename Policy = circ::prod_cons<relat::single, relat::multi, trans::broadcast>>
|
||||||
circ::relat::multi,
|
|
||||||
circ::trans::broadcast>>
|
|
||||||
class queue {
|
class queue {
|
||||||
public:
|
public:
|
||||||
using array_t = elem_array<sizeof(T), Policy>;
|
using array_t = elem_array<sizeof(T), Policy>;
|
||||||
|
|||||||
@ -31,6 +31,16 @@ enum : std::size_t {
|
|||||||
data_length = 16
|
data_length = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class relat { // multiplicity of the relationship
|
||||||
|
single,
|
||||||
|
multi
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class trans { // transmission
|
||||||
|
unicast,
|
||||||
|
broadcast
|
||||||
|
};
|
||||||
|
|
||||||
// concept helpers
|
// concept helpers
|
||||||
|
|
||||||
template <bool Cond, typename R>
|
template <bool Cond, typename R>
|
||||||
|
|||||||
@ -139,7 +139,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
using route = channel_ipml<channel_detail<
|
using route = channel_ipml<channel_detail<
|
||||||
circ::queue,
|
circ::queue,
|
||||||
circ::prod_cons<circ::relat::single, circ::relat::multi, circ::trans::broadcast>
|
circ::prod_cons<relat::single, relat::multi, trans::broadcast>
|
||||||
>>;
|
>>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -152,7 +152,7 @@ using route = channel_ipml<channel_detail<
|
|||||||
|
|
||||||
using channel = channel_ipml<channel_detail<
|
using channel = channel_ipml<channel_detail<
|
||||||
circ::queue,
|
circ::queue,
|
||||||
circ::prod_cons<circ::relat::multi, circ::relat::multi, circ::trans::broadcast>
|
circ::prod_cons<relat::multi, relat::multi, trans::broadcast>
|
||||||
>>;
|
>>;
|
||||||
|
|
||||||
} // namespace ipc
|
} // namespace ipc
|
||||||
|
|||||||
10
src/ipc.cpp
10
src/ipc.cpp
@ -261,10 +261,10 @@ buff_t channel_detail<Queue, Policy>::recv(handle_t h) {
|
|||||||
return detail<Queue, Policy>::recv(h);
|
return detail<Queue, Policy>::recv(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
template struct channel_detail<circ::queue, circ::prod_cons<circ::relat::single, circ::relat::single, circ::trans::unicast >>;
|
template struct channel_detail<circ::queue, circ::prod_cons<relat::single, relat::single, trans::unicast >>;
|
||||||
template struct channel_detail<circ::queue, circ::prod_cons<circ::relat::single, circ::relat::multi , circ::trans::unicast >>;
|
template struct channel_detail<circ::queue, circ::prod_cons<relat::single, relat::multi , trans::unicast >>;
|
||||||
template struct channel_detail<circ::queue, circ::prod_cons<circ::relat::multi , circ::relat::multi , circ::trans::unicast >>;
|
template struct channel_detail<circ::queue, circ::prod_cons<relat::multi , relat::multi , trans::unicast >>;
|
||||||
template struct channel_detail<circ::queue, circ::prod_cons<circ::relat::single, circ::relat::multi , circ::trans::broadcast>>;
|
template struct channel_detail<circ::queue, circ::prod_cons<relat::single, relat::multi , trans::broadcast>>;
|
||||||
template struct channel_detail<circ::queue, circ::prod_cons<circ::relat::multi , circ::relat::multi , circ::trans::broadcast>>;
|
template struct channel_detail<circ::queue, circ::prod_cons<relat::multi , relat::multi , trans::broadcast>>;
|
||||||
|
|
||||||
} // namespace ipc
|
} // namespace ipc
|
||||||
|
|||||||
@ -19,9 +19,9 @@ struct msg_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
using cq_t = ipc::circ::elem_array<sizeof(msg_t),
|
using cq_t = ipc::circ::elem_array<sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::single,
|
ipc::circ::prod_cons<ipc::relat::single,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::broadcast>>;
|
ipc::trans::broadcast>>;
|
||||||
cq_t* cq__;
|
cq_t* cq__;
|
||||||
|
|
||||||
bool operator==(msg_t const & m1, msg_t const & m2) {
|
bool operator==(msg_t const & m1, msg_t const & m2) {
|
||||||
@ -66,10 +66,10 @@ struct test_verify<ipc::circ::elem_array<D, P>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <ipc::circ::relat Rp>
|
template <ipc::relat Rp>
|
||||||
struct test_verify<ipc::circ::prod_cons<Rp,
|
struct test_verify<ipc::circ::prod_cons<Rp,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> : test_verify<cq_t> {
|
> : test_verify<cq_t> {
|
||||||
using test_verify<cq_t>::test_verify;
|
using test_verify<cq_t>::test_verify;
|
||||||
|
|
||||||
@ -93,13 +93,13 @@ struct test_verify<ipc::circ::prod_cons<Rp,
|
|||||||
template <typename P>
|
template <typename P>
|
||||||
struct quit_mode;
|
struct quit_mode;
|
||||||
|
|
||||||
template <ipc::circ::relat Rp, ipc::circ::relat Rc>
|
template <ipc::relat Rp, ipc::relat Rc>
|
||||||
struct quit_mode<ipc::circ::prod_cons<Rp, Rc, ipc::circ::trans::unicast>> {
|
struct quit_mode<ipc::circ::prod_cons<Rp, Rc, ipc::trans::unicast>> {
|
||||||
using type = volatile bool;
|
using type = volatile bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <ipc::circ::relat Rp, ipc::circ::relat Rc>
|
template <ipc::relat Rp, ipc::relat Rc>
|
||||||
struct quit_mode<ipc::circ::prod_cons<Rp, Rc, ipc::circ::trans::broadcast>> {
|
struct quit_mode<ipc::circ::prod_cons<Rp, Rc, ipc::trans::broadcast>> {
|
||||||
struct type {
|
struct type {
|
||||||
constexpr type(bool) {}
|
constexpr type(bool) {}
|
||||||
constexpr operator bool() const { return false; }
|
constexpr operator bool() const { return false; }
|
||||||
@ -263,27 +263,27 @@ void test_prod_cons() {
|
|||||||
void Unit::test_prod_cons_1v1() {
|
void Unit::test_prod_cons_1v1() {
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::single,
|
ipc::circ::prod_cons<ipc::relat::single,
|
||||||
ipc::circ::relat::single,
|
ipc::relat::single,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_ssu;
|
> el_arr_ssu;
|
||||||
benchmark_prod_cons<1, 1, LoopCount, cq_t>(&el_arr_ssu);
|
benchmark_prod_cons<1, 1, LoopCount, cq_t>(&el_arr_ssu);
|
||||||
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_ssu);
|
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_ssu);
|
||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::single,
|
ipc::circ::prod_cons<ipc::relat::single,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_smu;
|
> el_arr_smu;
|
||||||
benchmark_prod_cons<1, 1, LoopCount, decltype(el_arr_smu)::policy_t>(&el_arr_smu);
|
benchmark_prod_cons<1, 1, LoopCount, decltype(el_arr_smu)::policy_t>(&el_arr_smu);
|
||||||
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_smu);
|
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_smu);
|
||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_mmu;
|
> el_arr_mmu;
|
||||||
benchmark_prod_cons<1, 1, LoopCount, decltype(el_arr_mmu)::policy_t>(&el_arr_mmu);
|
benchmark_prod_cons<1, 1, LoopCount, decltype(el_arr_mmu)::policy_t>(&el_arr_mmu);
|
||||||
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_mmu);
|
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_mmu);
|
||||||
@ -293,9 +293,9 @@ void Unit::test_prod_cons_1v1() {
|
|||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::broadcast>
|
ipc::trans::broadcast>
|
||||||
> el_arr_mmb;
|
> el_arr_mmb;
|
||||||
benchmark_prod_cons<1, 1, LoopCount, cq_t>(&el_arr_mmb);
|
benchmark_prod_cons<1, 1, LoopCount, cq_t>(&el_arr_mmb);
|
||||||
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_mmb);
|
benchmark_prod_cons<1, 1, LoopCount, void>(&el_arr_mmb);
|
||||||
@ -304,18 +304,18 @@ void Unit::test_prod_cons_1v1() {
|
|||||||
void Unit::test_prod_cons_1v3() {
|
void Unit::test_prod_cons_1v3() {
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::single,
|
ipc::circ::prod_cons<ipc::relat::single,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_smu;
|
> el_arr_smu;
|
||||||
benchmark_prod_cons<1, 3, LoopCount, decltype(el_arr_smu)::policy_t>(&el_arr_smu);
|
benchmark_prod_cons<1, 3, LoopCount, decltype(el_arr_smu)::policy_t>(&el_arr_smu);
|
||||||
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_smu);
|
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_smu);
|
||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_mmu;
|
> el_arr_mmu;
|
||||||
benchmark_prod_cons<1, 3, LoopCount, decltype(el_arr_mmu)::policy_t>(&el_arr_mmu);
|
benchmark_prod_cons<1, 3, LoopCount, decltype(el_arr_mmu)::policy_t>(&el_arr_mmu);
|
||||||
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_mmu);
|
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_mmu);
|
||||||
@ -325,9 +325,9 @@ void Unit::test_prod_cons_1v3() {
|
|||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::broadcast>
|
ipc::trans::broadcast>
|
||||||
> el_arr_mmb;
|
> el_arr_mmb;
|
||||||
benchmark_prod_cons<1, 3, LoopCount, cq_t>(&el_arr_mmb);
|
benchmark_prod_cons<1, 3, LoopCount, cq_t>(&el_arr_mmb);
|
||||||
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_mmb);
|
benchmark_prod_cons<1, 3, LoopCount, void>(&el_arr_mmb);
|
||||||
@ -336,9 +336,9 @@ void Unit::test_prod_cons_1v3() {
|
|||||||
void Unit::test_prod_cons_performance() {
|
void Unit::test_prod_cons_performance() {
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::single,
|
ipc::circ::prod_cons<ipc::relat::single,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_smu;
|
> el_arr_smu;
|
||||||
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_smu](auto index) {
|
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_smu](auto index) {
|
||||||
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_smu);
|
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_smu);
|
||||||
@ -351,9 +351,9 @@ void Unit::test_prod_cons_performance() {
|
|||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::unicast>
|
ipc::trans::unicast>
|
||||||
> el_arr_mmu;
|
> el_arr_mmu;
|
||||||
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_mmu](auto index) {
|
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_mmu](auto index) {
|
||||||
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_mmu);
|
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_mmu);
|
||||||
@ -367,9 +367,9 @@ void Unit::test_prod_cons_performance() {
|
|||||||
|
|
||||||
ipc::circ::elem_array<
|
ipc::circ::elem_array<
|
||||||
sizeof(msg_t),
|
sizeof(msg_t),
|
||||||
ipc::circ::prod_cons<ipc::circ::relat::multi,
|
ipc::circ::prod_cons<ipc::relat::multi,
|
||||||
ipc::circ::relat::multi,
|
ipc::relat::multi,
|
||||||
ipc::circ::trans::broadcast>
|
ipc::trans::broadcast>
|
||||||
> el_arr_mmb;
|
> el_arr_mmb;
|
||||||
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_mmb](auto index) {
|
ipc::mem::detail::static_for(std::make_index_sequence<10>{}, [&el_arr_mmb](auto index) {
|
||||||
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_mmb);
|
benchmark_prod_cons<1, decltype(index)::value + 1, LoopCount, void>(&el_arr_mmb);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user