From af6ac84110e96ebeb5112796f290a12065ca7256 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Fri, 1 Jan 2021 12:39:32 +0800 Subject: [PATCH] add comments --- include/libipc/ipc.h | 10 ++++++++-- src/ipc.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/libipc/ipc.h b/include/libipc/ipc.h index ed50d8e..b2569a9 100755 --- a/include/libipc/ipc.h +++ b/include/libipc/ipc.h @@ -117,6 +117,9 @@ public: return chan_wrapper(name).wait_for_recv(r_count, tm); } + /** + * If timeout, this function would call 'force_push' to send the data forcibly. + */ bool send(void const * data, std::size_t size, std::size_t tm = default_timeout) { return detail_t::send(h_, data, size, tm); } @@ -127,6 +130,9 @@ public: return this->send(str.c_str(), str.size() + 1, tm); } + /** + * If timeout, this function would just return false. + */ bool try_send(void const * data, std::size_t size, std::size_t tm = default_timeout) { return detail_t::try_send(h_, data, size, tm); } @@ -149,7 +155,7 @@ public: template using chan = chan_wrapper>; -/* +/** * class route * * You could use one producer/server/sender for sending messages to a route, @@ -162,7 +168,7 @@ using chan = chan_wrapper>; using route = chan; -/* +/** * class channel * * You could use multi producers/writers for sending messages to a channel, diff --git a/src/ipc.cpp b/src/ipc.cpp index f2ddd37..9bfa291 100755 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -357,14 +357,14 @@ static void disconnect(ipc::handle_t h) { } } -static bool reconnect(ipc::handle_t * ph, bool start) { +static bool reconnect(ipc::handle_t * ph, bool start_to_recv) { assert(ph != nullptr); assert(*ph != nullptr); auto que = queue_of(*ph); if (que == nullptr) { return false; } - if (start) { + if (start_to_recv) { if (que->connect()) { // wouldn't connect twice info_of(*ph)->cc_waiter_.broadcast(); } @@ -376,12 +376,12 @@ static bool reconnect(ipc::handle_t * ph, bool start) { return true; } -static bool connect(ipc::handle_t * ph, char const * name, bool start) { +static bool connect(ipc::handle_t * ph, char const * name, bool start_to_recv) { assert(ph != nullptr); if (*ph == nullptr) { *ph = ipc::mem::alloc(name); } - return reconnect(ph, start); + return reconnect(ph, start_to_recv); } static void destroy(ipc::handle_t h) {