From 7c9acb3616fb3e0950f3797bfaa641a60c15b6eb Mon Sep 17 00:00:00 2001 From: Ypatia Tsavliri Date: Mon, 2 Dec 2024 10:58:03 +0200 Subject: [PATCH] Fix compilation issues --- tiledb/common/thread_pool/thread_pool.h | 30 +++++++++++++++++-------- tiledb/sm/query/readers/dense_reader.cc | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tiledb/common/thread_pool/thread_pool.h b/tiledb/common/thread_pool/thread_pool.h index 8e576d67023..100a641e073 100644 --- a/tiledb/common/thread_pool/thread_pool.h +++ b/tiledb/common/thread_pool/thread_pool.h @@ -52,9 +52,13 @@ class ThreadPool { */ class ThreadPoolTask { public: - ThreadPoolTask() = default; + ThreadPoolTask() = delete; ThreadPoolTask(ThreadPool* tp) - : tp_(tp){}; + : tp_(tp) { + if (tp == nullptr) { + throw std::runtime_error("Cannot construct task for a null threadpool"); + } + }; virtual ~ThreadPoolTask(){}; protected: @@ -79,11 +83,15 @@ class ThreadPool { */ class Task : public ThreadPoolTask { public: + Task() = delete; + /** - * Default constructor - * @brief Default constructed SharedTask is possible but not valid(). + * Constructor + * @brief Initializes only the threadpool but the future it encapsulates is + * not valid(). */ - Task() = default; + Task(ThreadPool* tp) + : ThreadPoolTask(tp){}; /** * Constructor from std::future @@ -165,11 +173,15 @@ class ThreadPool { */ class SharedTask : public ThreadPoolTask { public: + SharedTask() = delete; + /** - * Default constructor - * @brief Default constructed SharedTask is possible but not valid(). + * Constructor + * @brief Initializes only the threadpool but the shared_future it + * encapsulates is not valid(). */ - SharedTask() = default; + SharedTask(ThreadPool* tp) + : ThreadPoolTask(tp){}; /** * Constructor from std::shared_future @@ -318,7 +330,7 @@ class ThreadPool { template auto async(Fn&& f, Args&&... args) { if (concurrency_level_ == 0) { - Task invalid_future; + Task invalid_future(this); LOG_ERROR("Cannot execute task; thread pool uninitialized."); return invalid_future; } diff --git a/tiledb/sm/query/readers/dense_reader.cc b/tiledb/sm/query/readers/dense_reader.cc index 506e4cf35a7..684c0b302eb 100644 --- a/tiledb/sm/query/readers/dense_reader.cc +++ b/tiledb/sm/query/readers/dense_reader.cc @@ -368,7 +368,7 @@ Status DenseReader::dense_read() { // This is as far as we should go before implementing this properly in a task // graph, where the start and end of every piece of work can clearly be // identified. - ThreadPool::SharedTask compute_task; + ThreadPool::SharedTask compute_task(&resources_.compute_tp()); // Allow to disable the parallel read/compute in case the memory budget // doesn't allow it.