blob: ffceede6faac7e604651ea662a073b9109f9cd56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#pragma once
#include "events.h"
#include "mutex.h"
class TContCondVar {
public:
int WaitD(TCont* current, TContMutex* mutex, TInstant deadline) {
mutex->UnLock();
const int ret = WaitQueue_.WaitD(current, deadline);
if (ret != EWAKEDUP) {
return ret;
}
return mutex->LockD(current, deadline);
}
int WaitT(TCont* current, TContMutex* mutex, TDuration timeout) {
return WaitD(current, mutex, timeout.ToDeadLine());
}
int WaitI(TCont* current, TContMutex* mutex) {
return WaitD(current, mutex, TInstant::Max());
}
void Signal() noexcept {
WaitQueue_.Signal();
}
void BroadCast() noexcept {
WaitQueue_.BroadCast();
}
private:
TContWaitQueue WaitQueue_;
};
|