Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
cond.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_core/target_posix/roc_core/cond.h
10
//! @brief Condition variable.
11
12
#ifndef ROC_CORE_COND_H_
13
#define ROC_CORE_COND_H_
14
15
#include <errno.h>
16
#include <pthread.h>
17
18
#include "
roc_core/atomic.h
"
19
#include "
roc_core/attributes.h
"
20
#include "
roc_core/mutex.h
"
21
#include "
roc_core/noncopyable.h
"
22
#include "
roc_core/time.h
"
23
24
namespace
roc
{
25
namespace
core
{
26
27
//! Condition variable.
28
class
Cond
:
public
NonCopyable<> {
29
public
:
30
//! Initialize.
31
Cond
(
const
Mutex
& mutex);
32
33
//! Destroy.
34
~Cond
();
35
36
//! Wait with timeout.
37
//! @returns false if timeout expired.
38
ROC_ATTR_NODISCARD
bool
timed_wait
(
nanoseconds_t
timeout)
const
;
39
40
//! Wait.
41
void
wait
()
const
;
42
43
//! Wake up one pending waits.
44
void
signal
()
const
;
45
46
//! Wake up all pending waits.
47
void
broadcast
()
const
;
48
49
private
:
50
mutable
pthread_cond_t cond_;
51
mutable
Atomic<int>
guard_;
52
53
pthread_mutex_t& mutex_;
54
};
55
56
}
// namespace core
57
}
// namespace roc
58
59
#endif
// ROC_CORE_COND_H_
atomic.h
Atomic.
attributes.h
Compiler attributes.
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::core::Atomic
Atomic integer. Provides sequential consistency. For a fine-grained memory order control,...
Definition
atomic.h:26
roc::core::Cond::signal
void signal() const
Wake up one pending waits.
roc::core::Cond::Cond
Cond(const Mutex &mutex)
Initialize.
roc::core::Cond::~Cond
~Cond()
Destroy.
roc::core::Cond::wait
void wait() const
Wait.
roc::core::Cond::broadcast
void broadcast() const
Wake up all pending waits.
roc::core::Cond::timed_wait
ROC_ATTR_NODISCARD bool timed_wait(nanoseconds_t timeout) const
Wait with timeout.
roc::core::Mutex
Mutex.
Definition
mutex.h:31
mutex.h
Mutex.
roc::core
General-purpose building blocks and platform abstraction layer.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc
Root namespace.
noncopyable.h
Non-copyable object.
time.h
Time definitions.
roc_core
target_posix
roc_core
cond.h
Generated by
1.17.0