mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Make it possible to override the synchonization primitives used by the threadpool using macros.
This commit is contained in:
@@ -33,7 +33,7 @@ class Barrier {
|
||||
eigen_plain_assert(((v + 2) & ~1) != 0);
|
||||
return; // either count has not dropped to 0, or waiter is not waiting
|
||||
}
|
||||
std::unique_lock<std::mutex> l(mu_);
|
||||
EIGEN_MUTEX_LOCK l(mu_);
|
||||
eigen_plain_assert(!notified_);
|
||||
notified_ = true;
|
||||
cv_.notify_all();
|
||||
@@ -42,15 +42,15 @@ class Barrier {
|
||||
void Wait() {
|
||||
unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel);
|
||||
if ((v >> 1) == 0) return;
|
||||
std::unique_lock<std::mutex> l(mu_);
|
||||
EIGEN_MUTEX_LOCK l(mu_);
|
||||
while (!notified_) {
|
||||
cv_.wait(l);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mu_;
|
||||
std::condition_variable cv_;
|
||||
EIGEN_MUTEX mu_;
|
||||
EIGEN_CONDVAR cv_;
|
||||
std::atomic<unsigned int> state_; // low bit is waiter flag
|
||||
bool notified_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user