diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-08-12 22:13:29 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-09-01 14:33:33 +0000 |
commit | 6a37da837e1c936200f8d71a142973cc60b17b32 (patch) | |
tree | 922c9eff10660a49a16249781b05e5b8e1b5fc97 /src/common/threadpool.h | |
parent | Merge pull request #6586 (diff) | |
download | monero-6a37da837e1c936200f8d71a142973cc60b17b32.tar.xz |
threadpool: guard against exceptions in jobs, and armour plating
Those would, if uncaught, exit run and leave the waiter to wait
indefinitely for the number of active jobs to reach 0
Diffstat (limited to '')
-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(); }; |