Skip to content

Commit 6ec3d03

Browse files
updated workstealing
1 parent 072dd42 commit 6ec3d03

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

example/taskflow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
\
2727
std::cout << "Taskflow [speculative executor]: " \
2828
<< F<tf::BasicTaskflow<tf::SpeculativeThreadpool>>() \
29+
<< " ms\n"; \
30+
\
31+
std::cout << "Taskflow [privatized executor]: " \
32+
<< F<tf::BasicTaskflow<tf::PrivatizedThreadpool>>() \
2933
<< " ms\n"; \
3034

3135
// ============================================================================

taskflow/threadpool/privatized_threadpool.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,19 +535,19 @@ void PrivatizedThreadpool<Closure>::emplace(ArgsT&&... args){
535535
// Privatized queue of worker. The lock-free queue is inspired by
536536
// http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
537537
template<typename T, size_t C>
538-
class PrivatizedClosureQueue {
538+
class PrivatizedWorkQueue {
539539

540540
public:
541541

542-
PrivatizedClosureQueue() : _buffer_mask(C - 1) {
542+
PrivatizedWorkQueue() : _buffer_mask(C - 1) {
543543
for (size_t i = 0; i < C; i ++){
544544
_buffer[i].sequence_.store(i, std::memory_order_relaxed);
545545
}
546546
_front.store(0, std::memory_order_relaxed);
547547
_back.store(0, std::memory_order_relaxed);
548548
}
549549

550-
~PrivatizedClosureQueue(){}
550+
~PrivatizedWorkQueue(){}
551551

552552
bool enqueue(T& data){
553553
size_t pos = _front.load(std::memory_order_relaxed);
@@ -617,7 +617,7 @@ class PrivatizedThreadpool {
617617

618618
struct Worker{
619619
std::condition_variable cv;
620-
PrivatizedClosureQueue<Closure, 1024> queue;
620+
PrivatizedWorkQueue<Closure, 1024> queue;
621621
std::optional<Closure> cache;
622622
bool exit {false};
623623

0 commit comments

Comments
 (0)