File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,10 @@ class conn_head<P, true> : public conn_head_base {
7474 return this ->cc_ .fetch_and (~cc_id, std::memory_order_acq_rel) & ~cc_id;
7575 }
7676
77+ bool connected (cc_t cc_id) const noexcept {
78+ return (this ->connections () & cc_id) != 0 ;
79+ }
80+
7781 std::size_t conn_count (std::memory_order order = std::memory_order_acquire) const noexcept {
7882 cc_t cur = this ->cc_ .load (order);
7983 cc_t cnt; // accumulates the total bits set in cc
@@ -100,6 +104,11 @@ class conn_head<P, false> : public conn_head_base {
100104 }
101105 }
102106
107+ bool connected (cc_t cc_id) const noexcept {
108+ // In non-broadcast mode, connection tags are only used for counting.
109+ return (this ->connections () != 0 ) && (cc_id != 0 );
110+ }
111+
103112 std::size_t conn_count (std::memory_order order = std::memory_order_acquire) const noexcept {
104113 return this ->connections (order);
105114 }
Original file line number Diff line number Diff line change @@ -628,7 +628,7 @@ static ipc::buff_t recv(ipc::handle_t h, std::uint64_t tm) {
628628 // pop a new message
629629 typename queue_t ::value_t msg {};
630630 if (!wait_for (inf->rd_waiter_ , [que, &msg, &h] {
631- if (!que->connected (que-> elems () )) {
631+ if (!que->connected ()) {
632632 reconnect (&h, true );
633633 }
634634 return !que->pop (msg);
Original file line number Diff line number Diff line change @@ -63,13 +63,9 @@ class queue_conn {
6363 shm::handle::clear_storage (name);
6464 }
6565
66- bool connected () const noexcept {
67- return connected_ != 0 ;
68- }
69-
7066 template <typename Elems>
71- bool connected (Elems* elems) noexcept {
72- return connected_ & elems->connections ( );
67+ bool connected (Elems* elems) const noexcept {
68+ return elems->connected (connected_ );
7369 }
7470
7571 circ::cc_t connected_id () const noexcept {
@@ -155,6 +151,10 @@ class queue_base : public queue_conn {
155151 elems_->disconnect_sender ();
156152 }
157153
154+ bool connected () const noexcept {
155+ return base_t::connected (elems_);
156+ }
157+
158158 bool connect () noexcept {
159159 auto tp = base_t::connect (elems_);
160160 if (std::get<0 >(tp) && std::get<1 >(tp)) {
You can’t perform that action at this time.
0 commit comments