Skip to content

Commit 7c9acb3

Browse files
committed
Fix compilation issues
1 parent 77b52a2 commit 7c9acb3

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

tiledb/common/thread_pool/thread_pool.h

+21-9
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ class ThreadPool {
5252
*/
5353
class ThreadPoolTask {
5454
public:
55-
ThreadPoolTask() = default;
55+
ThreadPoolTask() = delete;
5656
ThreadPoolTask(ThreadPool* tp)
57-
: tp_(tp){};
57+
: tp_(tp) {
58+
if (tp == nullptr) {
59+
throw std::runtime_error("Cannot construct task for a null threadpool");
60+
}
61+
};
5862
virtual ~ThreadPoolTask(){};
5963

6064
protected:
@@ -79,11 +83,15 @@ class ThreadPool {
7983
*/
8084
class Task : public ThreadPoolTask {
8185
public:
86+
Task() = delete;
87+
8288
/**
83-
* Default constructor
84-
* @brief Default constructed SharedTask is possible but not valid().
89+
* Constructor
90+
* @brief Initializes only the threadpool but the future it encapsulates is
91+
* not valid().
8592
*/
86-
Task() = default;
93+
Task(ThreadPool* tp)
94+
: ThreadPoolTask(tp){};
8795

8896
/**
8997
* Constructor from std::future
@@ -165,11 +173,15 @@ class ThreadPool {
165173
*/
166174
class SharedTask : public ThreadPoolTask {
167175
public:
176+
SharedTask() = delete;
177+
168178
/**
169-
* Default constructor
170-
* @brief Default constructed SharedTask is possible but not valid().
179+
* Constructor
180+
* @brief Initializes only the threadpool but the shared_future it
181+
* encapsulates is not valid().
171182
*/
172-
SharedTask() = default;
183+
SharedTask(ThreadPool* tp)
184+
: ThreadPoolTask(tp){};
173185

174186
/**
175187
* Constructor from std::shared_future
@@ -318,7 +330,7 @@ class ThreadPool {
318330
template <class Fn, class... Args>
319331
auto async(Fn&& f, Args&&... args) {
320332
if (concurrency_level_ == 0) {
321-
Task invalid_future;
333+
Task invalid_future(this);
322334
LOG_ERROR("Cannot execute task; thread pool uninitialized.");
323335
return invalid_future;
324336
}

tiledb/sm/query/readers/dense_reader.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Status DenseReader::dense_read() {
368368
// This is as far as we should go before implementing this properly in a task
369369
// graph, where the start and end of every piece of work can clearly be
370370
// identified.
371-
ThreadPool::SharedTask compute_task;
371+
ThreadPool::SharedTask compute_task(&resources_.compute_tp());
372372

373373
// Allow to disable the parallel read/compute in case the memory budget
374374
// doesn't allow it.

0 commit comments

Comments
 (0)