44#include < future>
55#include < memory>
66#include < mutex>
7- #include < stack>
87#include < stdexcept>
98#include < utility>
109#include < vector>
@@ -166,16 +165,16 @@ namespace {
166165struct pending_threaded_processor : public pending_processor
167166{
168167 using output_vec_t = std::vector<std::shared_ptr<output_t >>;
169- using pending_queue_t = std::stack< osmid_t > ;
168+ using pending_queue_t = idlist_t ;
170169
171170 static osmid_t pop_id (pending_queue_t &queue, std::mutex &mutex)
172171 {
173172 osmid_t id = 0 ;
174173
175174 std::lock_guard<std::mutex> const lock{mutex};
176175 if (!queue.empty ()) {
177- id = queue.top ();
178- queue.pop ();
176+ id = queue.back ();
177+ queue.pop_back ();
179178 }
180179
181180 return id;
@@ -221,9 +220,6 @@ struct pending_threaded_processor : public pending_processor
221220
222221 pending_threaded_processor (std::shared_ptr<middle_t > mid,
223222 output_vec_t const &outs, size_t thread_count)
224- // note that we cant hint to the stack how large it should be ahead of time
225- // we could use a different datastructure like a deque or vector but then
226- // the outputs the enqueue jobs would need the version check for the push(_back) method
227223 : m_outputs(outs)
228224 {
229225 assert (!outs.empty ());
@@ -248,9 +244,9 @@ struct pending_threaded_processor : public pending_processor
248244 }
249245 }
250246
251- void enqueue_way (osmid_t id) override { m_queue.emplace (id); }
247+ void enqueue_way (osmid_t id) override { m_queue.push_back (id); }
252248
253- void enqueue_relation (osmid_t id) override { m_queue.emplace (id); }
249+ void enqueue_relation (osmid_t id) override { m_queue.push_back (id); }
254250
255251 template <typename FUNCTION>
256252 void process_queue (char const *type, FUNCTION &&function)
@@ -278,9 +274,7 @@ struct pending_threaded_processor : public pending_processor
278274 } catch (...) {
279275 // drain the queue, so that the other workers finish
280276 m_mutex.lock ();
281- while (!m_queue.empty ()) {
282- m_queue.pop ();
283- }
277+ m_queue.clear ();
284278 m_mutex.unlock ();
285279 throw ;
286280 }
0 commit comments