<p><b>@mmd-osm</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/osm2pgsql/pull/960#discussion_r334763876">db-copy.cpp</a>:</p>
<pre style='color:#555'>> @@ -28,9 +28,18 @@ db_copy_thread_t::~db_copy_thread_t() { finish(); }
void db_copy_thread_t::add_buffer(std::unique_ptr<db_cmd_t> &&buffer)
{
assert(m_worker.joinable()); // thread must not have been finished
- std::unique_lock<std::mutex> lock(m_queue_mutex);
- m_worker_queue.push_back(std::move(buffer));
- m_queue_cond.notify_one();
+
+ for (;;) {
+ std::unique_lock<std::mutex> lock(m_queue_mutex);
+ if (m_worker_queue.size() >= db_cmd_copy_t::Max_buffers) {
+ m_queue_full_cond.wait(lock);
</pre>
<p>just checked how this is done in <em>c++ concurrency in action</em>. They use a lambda function for the condition variable wait method: <a href="https://github.com/anthonywilliams/ccia_code_samples/blob/master/listings/listing_4.1.cpp#L47">https://github.com/anthonywilliams/ccia_code_samples/blob/master/listings/listing_4.1.cpp#L47</a> (code example is not about a bounded queue, it's just to show how they use condition variables throughout chapter 4).</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/pull/960?email_source=notifications&email_token=AA6353WT35HDULYXURQTC5TQOVMCRA5CNFSM4JATFEWKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCH5RJEA#pullrequestreview-301667472">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353RP245UVL3W26D74WDQOVMCRANCNFSM4JATFEWA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AA6353VC4QKOC76UK22HDULQOVMCRA5CNFSM4JATFEWKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCH5RJEA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/osm2pgsql/pull/960?email_source=notifications\u0026email_token=AA6353WT35HDULYXURQTC5TQOVMCRA5CNFSM4JATFEWKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCH5RJEA#pullrequestreview-301667472",
"url": "https://github.com/openstreetmap/osm2pgsql/pull/960?email_source=notifications\u0026email_token=AA6353WT35HDULYXURQTC5TQOVMCRA5CNFSM4JATFEWKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCH5RJEA#pullrequestreview-301667472",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>