Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
state_tracker.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 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_pipeline/state_tracker.h
10
//! @brief Pipeline state tracker.
11
12
#ifndef ROC_PIPELINE_STATE_TRACKER_H_
13
#define ROC_PIPELINE_STATE_TRACKER_H_
14
15
#include "
roc_core/atomic.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/stddefs.h
"
18
#include "
roc_sndio/device_state.h
"
19
20
namespace
roc
{
21
namespace
pipeline
{
22
23
//! Pipeline state tracker.
24
//!
25
//! All sender/receiver slots, endpoints, and sessions pass state updates to
26
//! the tracker, so that the top-level source/sink can quickly check if
27
//! there is any ongoing activity currently.
28
//!
29
//! Thread-safe.
30
class
StateTracker
:
public
core::NonCopyable
<> {
31
public
:
32
//! Initialize all counters to zero.
33
StateTracker
();
34
35
//! Compute current state.
36
sndio::DeviceState
get_state
()
const
;
37
38
//! Get active sessions counter.
39
size_t
num_active_sessions
()
const
;
40
41
//! Add/subtract to active sessions counter.
42
void
add_active_sessions
(
int
increment);
43
44
//! Get pending packets counter.
45
size_t
num_pending_packets
()
const
;
46
47
//! Add/subtract to pending packets counter.
48
void
add_pending_packets
(
int
increment);
49
50
private
:
51
core::Atomic<int>
active_sessions_;
52
core::Atomic<int>
pending_packets_;
53
};
54
55
}
// namespace pipeline
56
}
// namespace roc
57
58
#endif
// ROC_PIPELINE_STATE_TRACKER_H_
atomic.h
Atomic.
roc::core::Atomic
Atomic integer. Provides sequential consistency. For a fine-grained memory order control,...
Definition
atomic.h:26
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::pipeline::StateTracker::StateTracker
StateTracker()
Initialize all counters to zero.
roc::pipeline::StateTracker::add_pending_packets
void add_pending_packets(int increment)
Add/subtract to pending packets counter.
roc::pipeline::StateTracker::get_state
sndio::DeviceState get_state() const
Compute current state.
roc::pipeline::StateTracker::add_active_sessions
void add_active_sessions(int increment)
Add/subtract to active sessions counter.
roc::pipeline::StateTracker::num_active_sessions
size_t num_active_sessions() const
Get active sessions counter.
roc::pipeline::StateTracker::num_pending_packets
size_t num_pending_packets() const
Get pending packets counter.
device_state.h
Device state.
roc::pipeline
Sender and receiver processing pipelines.
roc::sndio::DeviceState
DeviceState
Device state.
Definition
device_state.h:19
roc
Root namespace.
noncopyable.h
Non-copyable object.
stddefs.h
Commonly used types and functions.
roc_pipeline
state_tracker.h
Generated by
1.17.0