aboutsummaryrefslogtreecommitdiff
path: root/src/common/threadpool.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-04-26 11:44:47 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-26 22:15:22 +0100
commit2771a18e85bd91dd881f89f6c14d26cba35a1844 (patch)
treeb8f710493bf453812f696b5392b17e6e72663d6f /src/common/threadpool.h
parentwallet2: remove unneeded divisions (diff)
downloadmonero-2771a18e85bd91dd881f89f6c14d26cba35a1844.tar.xz
threadpool: allow leaf functions to run concurrently
Decrease the number of worker threads by one to account for the fact the calling thread acts as a worker thread now
Diffstat (limited to 'src/common/threadpool.h')
-rw-r--r--src/common/threadpool.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/threadpool.h b/src/common/threadpool.h
index bf80a87f6..a43e38a76 100644
--- a/src/common/threadpool.h
+++ b/src/common/threadpool.h
@@ -59,7 +59,7 @@ public:
public:
void inc();
void dec();
- void wait(); //! Wait for a set of tasks to finish.
+ void wait(threadpool *tpool); //! Wait for a set of tasks to finish.
waiter() : num(0){}
~waiter();
};
@@ -67,7 +67,7 @@ public:
// Submit a task to the pool. The waiter pointer may be
// NULL if the caller doesn't care to wait for the
// task to finish.
- void submit(waiter *waiter, std::function<void()> f);
+ void submit(waiter *waiter, std::function<void()> f, bool leaf = false);
unsigned int get_max_concurrency() const;
@@ -78,6 +78,7 @@ public:
typedef struct entry {
waiter *wo;
std::function<void()> f;
+ bool leaf;
} entry;
std::deque<entry> queue;
boost::condition_variable has_work;
@@ -86,7 +87,7 @@ public:
unsigned int active;
unsigned int max;
bool running;
- void run();
+ void run(bool flush = false);
};
}