File tree 1 file changed +17
-7
lines changed
tiledb/common/thread_pool
1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ class ThreadPool {
60
60
protected:
61
61
friend class ThreadPool ;
62
62
63
- ThreadPool* tp_;
63
+ ThreadPool* tp_{ nullptr } ;
64
64
65
65
/* *
66
66
* Pure virtual functions that tasks need to implement so that they can be
@@ -119,11 +119,16 @@ class ThreadPool {
119
119
Task& operator =(const Task&) = delete ;
120
120
121
121
/* *
122
- * Wait in the threadpool for this task to be ready. Checks internally if a
123
- * task is valid.
122
+ * Wait in the threadpool for this task to be ready.
124
123
*/
125
124
Status wait () {
126
- return tp_->wait (this );
125
+ if (tp_ == nullptr ) {
126
+ throw std::runtime_error (" Cannot wait, threadpool is not initialized." );
127
+ } else if (!f_.valid ()) {
128
+ throw std::runtime_error (" Cannot wait, task is invalid." );
129
+ } else {
130
+ return tp_->wait (this );
131
+ }
127
132
}
128
133
129
134
/* *
@@ -234,11 +239,16 @@ class ThreadPool {
234
239
}
235
240
236
241
/* *
237
- * Wait in the threadpool for this task to be ready. Checks internally if a
238
- * task is valid.
242
+ * Wait in the threadpool for this task to be ready.
239
243
*/
240
244
Status wait () {
241
- return tp_->wait (this );
245
+ if (tp_ == nullptr ) {
246
+ throw std::runtime_error (" Cannot wait, threadpool is not initialized." );
247
+ } else if (!f_.valid ()) {
248
+ throw std::runtime_error (" Cannot wait, shared task is invalid." );
249
+ } else {
250
+ return tp_->wait (this );
251
+ }
242
252
}
243
253
244
254
/* *
You can’t perform that action at this time.
0 commit comments