1#ifndef ORIGINAL_SYNCPOINT_H
2#define ORIGINAL_SYNCPOINT_H
30 std::function<
void()> complete_func_;
31 std::exception_ptr e_;
83 : max_arrived_(0), arrived_(0), round_(0) {}
86 : max_arrived_(
max_arrived), arrived_(0), round_(0), complete_func_(
func) {}
91 if (max_arrived_ == 0) {
96 if (this->arrived_ != this->max_arrived_) {
97 this->condition_.wait(this->mutex_, [
this,
this_round]
103 if (this->complete_func_) {
105 this->complete_func_();
107 this->e_ = std::current_exception();
110 this->arrived_ -= this->max_arrived_;
112 this->condition_.notifyAll();
114 std::rethrow_exception(this->e_);
122 return this->max_arrived_;
128 return this->arrived_;
Definition condition.h:209
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Synchronization point for multiple threads.
Definition syncPoint.h:24
u_integer currentArrived() const
Get the current number of arrived threads.
Definition syncPoint.h:125
syncPoint()
Constructs a disabled synchronization point.
Definition syncPoint.h:82
u_integer maxArrived() const
Get the maximum number of threads required for synchronization.
Definition syncPoint.h:120
void arrive()
Arrive at the synchronization point.
Definition syncPoint.h:88
RAII wrapper for single mutex locking.
Definition mutex.h:280
Condition variable implementation for thread synchronization.
Cross-platform mutex and lock management utilities.
Main namespace for the project Original.
Definition algorithms.h:21