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 {
74
74
return this ->cc_ .fetch_and (~cc_id, std::memory_order_acq_rel) & ~cc_id;
75
75
}
76
76
77
+ bool connected (cc_t cc_id) const noexcept {
78
+ return (this ->connections () & cc_id) != 0 ;
79
+ }
80
+
77
81
std::size_t conn_count (std::memory_order order = std::memory_order_acquire) const noexcept {
78
82
cc_t cur = this ->cc_ .load (order);
79
83
cc_t cnt; // accumulates the total bits set in cc
@@ -100,6 +104,11 @@ class conn_head<P, false> : public conn_head_base {
100
104
}
101
105
}
102
106
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
+
103
112
std::size_t conn_count (std::memory_order order = std::memory_order_acquire) const noexcept {
104
113
return this ->connections (order);
105
114
}
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) {
628
628
// pop a new message
629
629
typename queue_t ::value_t msg {};
630
630
if (!wait_for (inf->rd_waiter_ , [que, &msg, &h] {
631
- if (!que->connected (que-> elems () )) {
631
+ if (!que->connected ()) {
632
632
reconnect (&h, true );
633
633
}
634
634
return !que->pop (msg);
Original file line number Diff line number Diff line change @@ -63,13 +63,9 @@ class queue_conn {
63
63
shm::handle::clear_storage (name);
64
64
}
65
65
66
- bool connected () const noexcept {
67
- return connected_ != 0 ;
68
- }
69
-
70
66
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_ );
73
69
}
74
70
75
71
circ::cc_t connected_id () const noexcept {
@@ -155,6 +151,10 @@ class queue_base : public queue_conn {
155
151
elems_->disconnect_sender ();
156
152
}
157
153
154
+ bool connected () const noexcept {
155
+ return base_t::connected (elems_);
156
+ }
157
+
158
158
bool connect () noexcept {
159
159
auto tp = base_t::connect (elems_);
160
160
if (std::get<0 >(tp) && std::get<1 >(tp)) {
You can’t perform that action at this time.
0 commit comments