aboutsummaryrefslogtreecommitdiff
path: root/src/common/threadpool.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-02-16 14:26:58 +0100
committerRiccardo Spagni <ric@spagni.net>2018-02-16 14:26:58 +0100
commitf4a6bc79d9a751480597aa007a1c6d315604f856 (patch)
tree6cd77005a74333cef7d9b0d62e311177417c2d0a /src/common/threadpool.cpp
parentMerge pull request #3252 (diff)
parentkeccak: fix mdlen bounds sanity checking (diff)
downloadmonero-f4a6bc79d9a751480597aa007a1c6d315604f856.tar.xz
Merge pull request #3226
e4646379 keccak: fix mdlen bounds sanity checking (moneromooo-monero) 2e3e90ac pass large parameters by const ref, not value (moneromooo-monero) 61defd89 blockchain: sanity check number of precomputed hash of hash blocks (moneromooo-monero) 9af6b2d1 ringct: fix infinite loop in unused h2b function (moneromooo-monero) 8cea8d0c simplewallet: double check a new multisig wallet is multisig (moneromooo-monero) 9b98a6ac threadpool: catch exceptions in dtor, to avoid terminate (moneromooo-monero) 24803ed9 blockchain_export: fix buffer overflow in exporter (moneromooo-monero) f3f7da62 perf_timer: rewrite to make it clear there is no division by zero (moneromooo-monero) c6ea3df0 performance_tests: remove add_arg call stray extra param (moneromooo-monero) fa6b4566 fuzz_tests: fix an uninitialized var in setup (moneromooo-monero) 03887f11 keccak: fix sanity check bounds test (moneromooo-monero) ad11db91 blockchain_db: initialize m_open in base class ctor (moneromooo-monero) bece67f9 miner: restore std::cout precision after modification (moneromooo-monero) 1aabd14c db_lmdb: check hard fork info drop succeeded (moneromooo-monero)
Diffstat (limited to 'src/common/threadpool.cpp')
-rw-r--r--src/common/threadpool.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index 7fd16ceaf..51e071577 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -25,6 +25,7 @@
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "misc_log_ex.h"
#include "common/threadpool.h"
#include <cassert>
@@ -81,6 +82,23 @@ int threadpool::get_max_concurrency() {
return max;
}
+threadpool::waiter::~waiter()
+{
+ {
+ boost::unique_lock<boost::mutex> lock(mt);
+ if (num)
+ MERROR("wait should have been called before waiter dtor - waiting now");
+ }
+ try
+ {
+ wait();
+ }
+ catch (const std::exception &e)
+ {
+ /* ignored */
+ }
+}
+
void threadpool::waiter::wait() {
boost::unique_lock<boost::mutex> lock(mt);
while(num) cv.wait(lock);