Make it possible to override the synchonization primitives used by the threadpool using macros.

This commit is contained in:
Rasmus Munk Larsen
2023-05-09 19:36:17 +00:00
parent 1321821e86
commit 96c42771d6
6 changed files with 27 additions and 17 deletions

View File

@@ -171,8 +171,8 @@ class EventCount {
// Align to 128 byte boundary to prevent false sharing with other Waiter
// objects in the same vector.
EIGEN_ALIGN_TO_BOUNDARY(128) std::atomic<uint64_t> next;
std::mutex mu;
std::condition_variable cv;
EIGEN_MUTEX mu;
EIGEN_CONDVAR cv;
uint64_t epoch = 0;
unsigned state = kNotSignaled;
enum {
@@ -220,7 +220,7 @@ class EventCount {
}
void Park(Waiter* w) {
std::unique_lock<std::mutex> lock(w->mu);
EIGEN_MUTEX_LOCK lock(w->mu);
while (w->state != Waiter::kSignaled) {
w->state = Waiter::kWaiting;
w->cv.wait(lock);
@@ -233,7 +233,7 @@ class EventCount {
next = wnext == kStackMask ? nullptr : &waiters_[wnext];
unsigned state;
{
std::unique_lock<std::mutex> lock(w->mu);
EIGEN_MUTEX_LOCK lock(w->mu);
state = w->state;
w->state = Waiter::kSignaled;
}