You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Queue implementation had a mechanism to know whether it was in use or in
the process of being shut down using the m_done atomic bool. But this
interfered with the externally used mechanism of putting special "end of data"
markers in the queue which could lead to a situation where queue readers
would not shutdown properly.
Copy file name to clipboardExpand all lines: include/osmium/thread/queue.hpp
+3-12Lines changed: 3 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,6 @@ namespace osmium {
73
73
/// Used to signal readers when data is available in the queue.
74
74
std::condition_variable m_data_available;
75
75
76
-
std::atomic<bool> m_done;
77
-
78
76
#ifdef OSMIUM_DEBUG_QUEUE_SIZE
79
77
/// The largest size the queue has been so far.
80
78
size_t m_largest_size;
@@ -111,8 +109,7 @@ namespace osmium {
111
109
m_name(name),
112
110
m_mutex(),
113
111
m_queue(),
114
-
m_data_available(),
115
-
m_done(false)
112
+
m_data_available()
116
113
#ifdef OSMIUM_DEBUG_QUEUE_SIZE
117
114
,
118
115
m_largest_size(0),
@@ -125,7 +122,6 @@ namespace osmium {
125
122
}
126
123
127
124
~Queue() {
128
-
shutdown();
129
125
#ifdef OSMIUM_DEBUG_QUEUE_SIZE
130
126
std::cerr << "queue '" << m_name << "' with max_size=" << m_max_size << " had largest size " << m_largest_size << " and was full " << m_full_counter << " times in " << m_push_counter << " push() calls and was empty " << m_empty_counter << " times in " << m_pop_counter << " pop() calls\n";
131
127
#endif
@@ -157,11 +153,6 @@ namespace osmium {
157
153
m_data_available.notify_one();
158
154
}
159
155
160
-
voidshutdown() {
161
-
m_done = true;
162
-
m_data_available.notify_all();
163
-
}
164
-
165
156
voidwait_and_pop(T& value) {
166
157
#ifdef OSMIUM_DEBUG_QUEUE_SIZE
167
158
++m_pop_counter;
@@ -173,7 +164,7 @@ namespace osmium {
173
164
}
174
165
#endif
175
166
m_data_available.wait(lock, [this] {
176
-
return !m_queue.empty() || m_done;
167
+
return !m_queue.empty();
177
168
});
178
169
if (!m_queue.empty()) {
179
170
value = std::move(m_queue.front());
@@ -192,7 +183,7 @@ namespace osmium {
192
183
}
193
184
#endif
194
185
if (!m_data_available.wait_for(lock, std::chrono::seconds(1), [this] {
0 commit comments