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 49dfadf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
46 changes: 29 additions & 17 deletions tiledb/common/thread_pool/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ class ThreadPool {
*/
class ThreadPoolTask {
public:
ThreadPoolTask() = default;
ThreadPoolTask() = delete;
ThreadPoolTask(ThreadPool* tp)
: tp_(tp){};
virtual ~ThreadPoolTask(){};
: tp_(tp) {
if (tp == nullptr) {
throw std::runtime_error("Cannot construct task for a null threadpool");
}
};
virtual ~ThreadPoolTask() {};

protected:
friend class ThreadPool;
Expand All @@ -79,25 +83,29 @@ 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
*/
Task(std::future<Status>&& f, ThreadPool* tp)
: ThreadPoolTask(tp)
, f_(std::move(f)){};
, f_(std::move(f)) {};

/**
* Move constructor
*/
Task(Task&& t) noexcept
: ThreadPoolTask(t.tp_)
, f_(std::move(t.f_)){};
, f_(std::move(t.f_)) {};

/**
* Move assignenent from Task
Expand Down Expand Up @@ -165,32 +173,36 @@ 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
*/
SharedTask(std::shared_future<Status>&& f, ThreadPool* tp)
: ThreadPoolTask(tp)
, f_(std::move(f)){};
, f_(std::move(f)) {};

/**
* Constructor from std::future
*/
SharedTask(std::future<Status>&& f, ThreadPool* tp) noexcept
: ThreadPoolTask(tp)
, f_(std::move(f)){};
, f_(std::move(f)) {};

/**
* Move constructor from a SharedTask
*/
SharedTask(SharedTask&& t) noexcept
: ThreadPoolTask(t.tp_)
, f_(std::move(t.f_)){};
, f_(std::move(t.f_)) {};

/**
* Move assignenent from SharedTask
Expand All @@ -206,7 +218,7 @@ class ThreadPool {
*/
SharedTask(Task&& t) noexcept
: ThreadPoolTask(t.tp_)
, f_(std::move(t.f_)){};
, f_(std::move(t.f_)) {};

/**
* Move assignenent from Task
Expand All @@ -222,7 +234,7 @@ class ThreadPool {
*/
SharedTask(const SharedTask& t) noexcept
: ThreadPoolTask(t.tp_)
, f_(t.f_){};
, f_(t.f_) {};

/**
* Copy assignenent
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 49dfadf

Please sign in to comment.