Deskflow
1.26.0.418
Keyboard and mouse sharing utility
Toggle main menu visibility
Loading...
Searching...
No Matches
CondVar.h
Go to the documentation of this file.
1
/*
2
* Deskflow -- mouse and keyboard sharing utility
3
* SPDX-FileCopyrightText: (C) 2012 - 2016 Synergy App Ltd
4
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
5
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6
*/
7
8
#pragma once
9
10
#include "
mt/Mutex.h
"
11
12
class
Stopwatch
;
13
15
21
class
CondVarBase
22
{
23
public
:
29
explicit
CondVarBase
(
Mutex
*mutex);
30
~CondVarBase
();
31
33
34
36
42
void
lock
()
const
;
43
45
void
unlock
()
const
;
46
48
52
void
signal
();
53
55
58
void
broadcast
();
59
61
63
65
84
bool
wait
(
double
timeout
= -1.0)
const
;
85
87
96
bool
wait
(
Stopwatch
&timer,
double
timeout
)
const
;
97
99
102
Mutex
*
getMutex
()
const
;
103
105
106
private
:
107
// not implemented
108
CondVarBase
(
const
CondVarBase
&);
109
CondVarBase
&operator=(
const
CondVarBase
&);
110
111
private
:
112
Mutex
*m_mutex;
113
ArchCond
m_cond;
114
};
115
117
120
template
<
class
T>
class
CondVar
:
public
CondVarBase
121
{
122
public
:
124
CondVar
(
Mutex
*mutex,
const
T &value);
126
CondVar
(
const
CondVar
&);
127
~CondVar
();
128
130
131
133
137
CondVar
&
operator=
(
const
CondVar
&cv);
138
140
144
CondVar
&
operator=
(
const
T &v);
145
147
149
151
155
operator
const
volatile
T &()
const
;
156
158
159
private
:
160
volatile
T m_data;
161
};
162
163
template
<
class
T>
inline
CondVar<T>::CondVar
(
Mutex
*mutex,
const
T &
data
) :
CondVarBase
(mutex), m_data(
data
)
164
{
165
// do nothing
166
}
167
168
template
<
class
T>
inline
CondVar<T>::CondVar
(
const
CondVar
&cv) :
CondVarBase
(cv.
getMutex
()), m_data(cv.m_data)
169
{
170
// do nothing
171
}
172
173
template
<
class
T>
inline
CondVar<T>::~CondVar
() =
default
;
174
175
template
<
class
T>
inline
CondVar<T>
&
CondVar<T>::operator=
(
const
CondVar<T>
&cv)
176
{
177
m_data = cv.m_data;
178
return
*
this
;
179
}
180
181
template
<
class
T>
inline
CondVar<T>
&
CondVar<T>::operator=
(
const
T &
data
)
182
{
183
m_data =
data
;
184
return
*
this
;
185
}
186
187
template
<
class
T>
inline
CondVar<T>::operator
const
volatile
T &()
const
188
{
189
return
m_data;
190
}
data
static int void FAR * data
Definition
ArchNetworkWinsock.cpp:36
timeout
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition
ArchNetworkWinsock.cpp:41
ArchCond
ArchCondImpl * ArchCond
Opaque condition variable type. An opaque type representing a condition variable.
Definition
IArchMultithread.h:26
Mutex.h
CondVarBase::signal
void signal()
Signal the condition variable.
Definition
CondVar.cpp:37
CondVarBase::lock
void lock() const
Lock the condition variable's mutex.
Definition
CondVar.cpp:27
CondVarBase::CondVarBase
CondVarBase(Mutex *mutex)
Definition
CondVar.cpp:16
CondVarBase::broadcast
void broadcast()
Signal the condition variable.
Definition
CondVar.cpp:42
CondVarBase::unlock
void unlock() const
Unlock the condition variable's mutex.
Definition
CondVar.cpp:32
CondVarBase::wait
bool wait(double timeout=-1.0) const
Wait on the condition variable.
Definition
CondVar.cpp:65
CondVarBase::getMutex
Mutex * getMutex() const
Get the mutex.
Definition
CondVar.cpp:70
CondVar::operator=
CondVar & operator=(const CondVar &cv)
Assigns the value of cv to this.
Definition
CondVar.h:175
CondVar::~CondVar
~CondVar()
CondVar::CondVar
CondVar(Mutex *mutex, const T &value)
Initialize using value.
Definition
CondVar.h:163
Mutex
Mutual exclusion.
Definition
Mutex.h:22
Stopwatch
A timer class.
Definition
Stopwatch.h:16
src
lib
mt
CondVar.h
Generated by
1.18.0