Skip to content

Commit

Permalink
Fix compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia committed Dec 2, 2024
1 parent 77b52a2 commit 7c9acb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions tiledb/common/thread_pool/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -318,7 +330,7 @@ class ThreadPool {
template <class Fn, class... Args>
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;
}
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/readers/dense_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7c9acb3

Please sign in to comment.