Skip to content

Commit ebf3735

Browse files
committed
Retire ConditionVariable
Now that we use spinlocks everywhere and don't put threads to sleep while idle, we can use the slower (but no more in hot path) std::condition_variable_any instead of our homwgrown ConditionVariable struct. Verified fo rno regression at STC with 7 threads: ELO: -0.66 +-2.7 (95%) LOS: 31.8% Total: 20000 W: 3210 L: 3248 D: 13542 No functional change
1 parent 966bc47 commit ebf3735

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

src/thread_win32.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,7 @@ struct Mutex {
5757
CRITICAL_SECTION cs;
5858
};
5959

60-
struct ConditionVariable {
61-
ConditionVariable() { hn = CreateEvent(0, FALSE, FALSE, 0); }
62-
~ConditionVariable() { CloseHandle(hn); }
63-
void notify_one() { SetEvent(hn); }
64-
65-
void wait(std::unique_lock<Mutex>& lk) {
66-
lk.unlock();
67-
WaitForSingleObject(hn, INFINITE);
68-
lk.lock();
69-
}
70-
71-
void wait_for(std::unique_lock<Mutex>& lk, const std::chrono::milliseconds& ms) {
72-
lk.unlock();
73-
WaitForSingleObject(hn, ms.count());
74-
lk.lock();
75-
}
76-
77-
template<class Predicate>
78-
void wait(std::unique_lock<Mutex>& lk, Predicate p) { while (!p()) this->wait(lk); }
79-
80-
private:
81-
HANDLE hn;
82-
};
60+
typedef std::condition_variable_any ConditionVariable;
8361

8462
#else // Default case: use STL classes
8563

0 commit comments

Comments
 (0)