aboutsummaryrefslogtreecommitdiff
path: root/src/ringct/rctSigs.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-18 13:19:26 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-18 13:19:26 +0200
commit1a73843ceca12932e57f57caf66033c69f8c0d1f (patch)
treef210349b2a9b5343876556c4ed379444de9c0fda /src/ringct/rctSigs.cpp
parentMerge pull request #2416 (diff)
parentTweak concurrency limits (diff)
downloadmonero-1a73843ceca12932e57f57caf66033c69f8c0d1f.tar.xz
Merge pull request #2446
6d0ca7d1 Tweak concurrency limits (Howard Chu) 510d0d47 Use a threadpool (Howard Chu)
Diffstat (limited to 'src/ringct/rctSigs.cpp')
-rw-r--r--src/ringct/rctSigs.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp
index 8efd6a07c..946325367 100644
--- a/src/ringct/rctSigs.cpp
+++ b/src/ringct/rctSigs.cpp
@@ -30,8 +30,7 @@
#include "misc_log_ex.h"
#include "common/perf_timer.h"
-#include "common/task_region.h"
-#include "common/thread_group.h"
+#include "common/threadpool.h"
#include "common/util.h"
#include "rctSigs.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
@@ -731,17 +730,16 @@ namespace rct {
try
{
if (semantics) {
+ tools::threadpool& tpool = tools::threadpool::getInstance();
+ tools::threadpool::waiter waiter;
std::deque<bool> results(rv.outPk.size(), false);
- tools::thread_group threadpool(tools::thread_group::optimal_with_max(rv.outPk.size()));
-
- tools::task_region(threadpool, [&] (tools::task_region_handle& region) {
- DP("range proofs verified?");
- for (size_t i = 0; i < rv.outPk.size(); i++) {
- region.run([&, i] {
- results[i] = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]);
- });
- }
- });
+ DP("range proofs verified?");
+ for (size_t i = 0; i < rv.outPk.size(); i++) {
+ tpool.submit(&waiter, [&, i] {
+ results[i] = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]);
+ });
+ }
+ waiter.wait();
for (size_t i = 0; i < rv.outPk.size(); ++i) {
if (!results[i]) {
@@ -794,7 +792,8 @@ namespace rct {
const size_t threads = std::max(rv.outPk.size(), rv.mixRing.size());
std::deque<bool> results(threads);
- tools::thread_group threadpool(tools::thread_group::optimal_with_max(threads));
+ tools::threadpool& tpool = tools::threadpool::getInstance();
+ tools::threadpool::waiter waiter;
if (semantics) {
key sumOutpks = identity();
@@ -819,13 +818,12 @@ namespace rct {
results.clear();
results.resize(rv.outPk.size());
- tools::task_region(threadpool, [&] (tools::task_region_handle& region) {
- for (size_t i = 0; i < rv.outPk.size(); i++) {
- region.run([&, i] {
- results[i] = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]);
- });
- }
- });
+ for (size_t i = 0; i < rv.outPk.size(); i++) {
+ tpool.submit(&waiter, [&, i] {
+ results[i] = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]);
+ });
+ }
+ waiter.wait();
for (size_t i = 0; i < results.size(); ++i) {
if (!results[i]) {
@@ -839,13 +837,12 @@ namespace rct {
results.clear();
results.resize(rv.mixRing.size());
- tools::task_region(threadpool, [&] (tools::task_region_handle& region) {
- for (size_t i = 0 ; i < rv.mixRing.size() ; i++) {
- region.run([&, i] {
+ for (size_t i = 0 ; i < rv.mixRing.size() ; i++) {
+ tpool.submit(&waiter, [&, i] {
results[i] = verRctMGSimple(message, rv.p.MGs[i], rv.mixRing[i], rv.pseudoOuts[i]);
- });
- }
- });
+ });
+ }
+ waiter.wait();
for (size_t i = 0; i < results.size(); ++i) {
if (!results[i]) {