简化接口

This commit is contained in:
mutouyun 2020-09-20 12:20:55 +08:00
parent 1323dc736b
commit 7545e17084
5 changed files with 13 additions and 15 deletions

View File

@ -1,19 +1,19 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <thread>
#include <regex>
#include <atomic>
#include "libipc/ipc.h" #include "libipc/ipc.h"
namespace { namespace {
constexpr char const name__[] = "ipc-msg-que"; constexpr char const name__[] = "ipc-msg-que";
constexpr char const quit__[] = "q"; constexpr char const mode_s__[] = "s";
constexpr char const id__ [] = "c"; constexpr char const mode_r__[] = "r";
using msg_que_t = ipc::chan<ipc::relat::single, ipc::relat::single, ipc::trans::unicast>;
} // namespace } // namespace
int main() { int main(int argc, char ** argv) {
if (argc < 2) return 0;
return 0; return 0;
} }

View File

@ -140,8 +140,8 @@ public:
} }
}; };
template <typename Flag> template <relat Rp, relat Rc, trans Ts>
using chan = chan_wrapper<Flag>; using chan = chan_wrapper<ipc::wr<Rp, Rc, Ts>>;
/* /*
* class route * class route
@ -154,7 +154,7 @@ using chan = chan_wrapper<Flag>;
* (one producer/writer to multi consumers/readers) * (one producer/writer to multi consumers/readers)
*/ */
using route = chan<ipc::wr<relat::single, relat::multi, trans::broadcast>>; using route = chan<relat::single, relat::multi, trans::broadcast>;
/* /*
* class channel * class channel
@ -164,6 +164,6 @@ using route = chan<ipc::wr<relat::single, relat::multi, trans::broadcast>>;
* would receive your sent messages. * would receive your sent messages.
*/ */
using channel = chan<ipc::wr<relat::multi, relat::multi, trans::broadcast>>; using channel = chan<relat::multi, relat::multi, trans::broadcast>;
} // namespace ipc } // namespace ipc

View File

@ -16,7 +16,6 @@
#include "libipc/waiter_helper.h" #include "libipc/waiter_helper.h"
#include "libipc/utility/log.h" #include "libipc/utility/log.h"
#include "libipc/utility/scope_guard.h"
#include "libipc/platform/detail.h" #include "libipc/platform/detail.h"
#include "libipc/memory/resource.h" #include "libipc/memory/resource.h"

View File

@ -13,7 +13,6 @@
#include "libipc/waiter_helper.h" #include "libipc/waiter_helper.h"
#include "libipc/utility/log.h" #include "libipc/utility/log.h"
#include "libipc/utility/scope_guard.h"
#include "libipc/platform/to_tchar.h" #include "libipc/platform/to_tchar.h"
#include "libipc/platform/get_sa.h" #include "libipc/platform/get_sa.h"
#include "libipc/platform/detail.h" #include "libipc/platform/detail.h"

View File

@ -52,7 +52,7 @@ public:
template <relat Rp, relat Rc, trans Ts> template <relat Rp, relat Rc, trans Ts>
void test_basic(char const * name) { void test_basic(char const * name) {
using que_t = chan<wr<Rp, Rc, Ts>>; using que_t = chan<Rp, Rc, Ts>;
rand_buf test1, test2; rand_buf test1, test2;
que_t que1 { name }; que_t que1 { name };
@ -69,7 +69,7 @@ void test_basic(char const * name) {
template <relat Rp, relat Rc, trans Ts> template <relat Rp, relat Rc, trans Ts>
void test_sr(char const * name, int size, int s_cnt, int r_cnt) { void test_sr(char const * name, int size, int s_cnt, int r_cnt) {
using que_t = chan<wr<Rp, Rc, Ts>>; using que_t = chan<Rp, Rc, Ts>;
ipc_ut::sender().start(static_cast<std::size_t>(s_cnt)); ipc_ut::sender().start(static_cast<std::size_t>(s_cnt));
ipc_ut::reader().start(static_cast<std::size_t>(r_cnt)); ipc_ut::reader().start(static_cast<std::size_t>(r_cnt));