diff options
author | luigi1111 <luigi1111w@gmail.com> | 2020-09-03 12:25:59 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2020-09-03 12:25:59 -0500 |
commit | ee0b02d0dbdafebd28aa535baae086f8d481d191 (patch) | |
tree | 7c188abaf0956567f56a6c44cf3adf0b397823f6 /src/common/threadpool.h | |
parent | Merge pull request #6789 (diff) | |
parent | threadpool: guard against exceptions in jobs, and armour plating (diff) | |
download | monero-ee0b02d0dbdafebd28aa535baae086f8d481d191.tar.xz |
Merge pull request #6757
6a37da8 threadpool: guard against exceptions in jobs, and armour plating (moneromooo-monero)
Diffstat (limited to 'src/common/threadpool.h')
-rw-r--r-- | src/common/threadpool.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/threadpool.h b/src/common/threadpool.h index 91f9fdf47..66b08fece 100644 --- a/src/common/threadpool.h +++ b/src/common/threadpool.h @@ -55,12 +55,16 @@ public: class waiter { boost::mutex mt; boost::condition_variable cv; + threadpool &pool; int num; + bool error_flag; public: void inc(); void dec(); - void wait(threadpool *tpool); //! Wait for a set of tasks to finish. - waiter() : num(0){} + bool wait(); //! Wait for a set of tasks to finish, returns false iff any error + void set_error() noexcept { error_flag = true; } + bool error() const noexcept { return error_flag; } + waiter(threadpool &pool) : pool(pool), num(0), error_flag(false) {} ~waiter(); }; |