Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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"
17#include "roc_core/stddefs.h"
19
20namespace roc {
21namespace 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.
31public:
32 //! Initialize all counters to zero.
34
35 //! Compute current state.
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
50private:
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.
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Pipeline state tracker.
StateTracker()
Initialize all counters to zero.
void add_pending_packets(int increment)
Add/subtract to pending packets counter.
sndio::DeviceState get_state() const
Compute current state.
void add_active_sessions(int increment)
Add/subtract to active sessions counter.
size_t num_active_sessions() const
Get active sessions counter.
size_t num_pending_packets() const
Get pending packets counter.
Device state.
DeviceState
Device state.
Root namespace.
Non-copyable object.
Commonly used types and functions.