mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
add comments
This commit is contained in:
parent
1202272077
commit
af6ac84110
@ -117,6 +117,9 @@ public:
|
|||||||
return chan_wrapper(name).wait_for_recv(r_count, tm);
|
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) {
|
bool send(void const * data, std::size_t size, std::size_t tm = default_timeout) {
|
||||||
return detail_t::send(h_, data, size, tm);
|
return detail_t::send(h_, data, size, tm);
|
||||||
}
|
}
|
||||||
@ -127,6 +130,9 @@ public:
|
|||||||
return this->send(str.c_str(), str.size() + 1, tm);
|
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) {
|
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);
|
return detail_t::try_send(h_, data, size, tm);
|
||||||
}
|
}
|
||||||
@ -149,7 +155,7 @@ public:
|
|||||||
template <relat Rp, relat Rc, trans Ts>
|
template <relat Rp, relat Rc, trans Ts>
|
||||||
using chan = chan_wrapper<ipc::wr<Rp, Rc, Ts>>;
|
using chan = chan_wrapper<ipc::wr<Rp, Rc, Ts>>;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* class route
|
* class route
|
||||||
*
|
*
|
||||||
* You could use one producer/server/sender for sending messages to a route,
|
* You could use one producer/server/sender for sending messages to a route,
|
||||||
@ -162,7 +168,7 @@ using chan = chan_wrapper<ipc::wr<Rp, Rc, Ts>>;
|
|||||||
|
|
||||||
using route = chan<relat::single, relat::multi, trans::broadcast>;
|
using route = chan<relat::single, relat::multi, trans::broadcast>;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* class channel
|
* class channel
|
||||||
*
|
*
|
||||||
* You could use multi producers/writers for sending messages to a channel,
|
* You could use multi producers/writers for sending messages to a channel,
|
||||||
|
|||||||
@ -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);
|
||||||
assert(*ph != nullptr);
|
assert(*ph != nullptr);
|
||||||
auto que = queue_of(*ph);
|
auto que = queue_of(*ph);
|
||||||
if (que == nullptr) {
|
if (que == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (start) {
|
if (start_to_recv) {
|
||||||
if (que->connect()) { // wouldn't connect twice
|
if (que->connect()) { // wouldn't connect twice
|
||||||
info_of(*ph)->cc_waiter_.broadcast();
|
info_of(*ph)->cc_waiter_.broadcast();
|
||||||
}
|
}
|
||||||
@ -376,12 +376,12 @@ static bool reconnect(ipc::handle_t * ph, bool start) {
|
|||||||
return true;
|
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);
|
assert(ph != nullptr);
|
||||||
if (*ph == nullptr) {
|
if (*ph == nullptr) {
|
||||||
*ph = ipc::mem::alloc<conn_info_t>(name);
|
*ph = ipc::mem::alloc<conn_info_t>(name);
|
||||||
}
|
}
|
||||||
return reconnect(ph, start);
|
return reconnect(ph, start_to_recv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(ipc::handle_t h) {
|
static void destroy(ipc::handle_t h) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user