aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/thread-pool.cc4
-rw-r--r--gdbsupport/thread-pool.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index bbe043d..0b11213 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -154,6 +154,7 @@ thread_pool::set_thread_count (size_t num_threads)
{
#if CXX_STD_THREAD
std::lock_guard<std::mutex> guard (m_tasks_mutex);
+ m_sized_at_least_once = true;
/* If the new size is larger, start some new threads. */
if (m_thread_count < num_threads)
@@ -197,6 +198,9 @@ thread_pool::set_thread_count (size_t num_threads)
void
thread_pool::do_post_task (std::packaged_task<void ()> &&func)
{
+ /* This assert is here to check that no tasks are posted to the pool between
+ its initialization and sizing. */
+ gdb_assert (m_sized_at_least_once);
std::packaged_task<void ()> t (std::move (func));
if (m_thread_count != 0)
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h
index d5e1dc7..6959414 100644
--- a/gdbsupport/thread-pool.h
+++ b/gdbsupport/thread-pool.h
@@ -204,6 +204,7 @@ private:
between the main thread and the worker threads. */
std::condition_variable m_tasks_cv;
std::mutex m_tasks_mutex;
+ bool m_sized_at_least_once = false;
#endif /* CXX_STD_THREAD */
};