Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
ticker.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/ticker.h
10
//! @brief Ticker.
11
12
#ifndef ROC_CORE_TICKER_H_
13
#define ROC_CORE_TICKER_H_
14
15
#include "
roc_core/noncopyable.h
"
16
#include "
roc_core/panic.h
"
17
#include "
roc_core/time.h
"
18
19
namespace
roc
{
20
namespace
core {
21
22
//! Ticker.
23
class
Ticker
:
public
NonCopyable
<> {
24
public
:
25
//! Number of ticks.
26
typedef
uint64_t
ticks_t
;
27
28
//! Initialize.
29
//! @remarks
30
//! @p freq defines the number of ticks per second.
31
explicit
Ticker
(
ticks_t
freq);
32
33
//! Start ticker.
34
void
start
();
35
36
//! Returns number of ticks elapsed since start.
37
//! If ticker is not started yet, it is started automatically.
38
ticks_t
elapsed
();
39
40
//! Wait until the given number of ticks elapses since start.
41
//! If ticker is not started yet, it is started automatically.
42
void
wait
(
ticks_t
ticks);
43
44
private
:
45
const
double
ratio_;
46
nanoseconds_t
start_;
47
bool
started_;
48
};
49
50
}
// namespace core
51
}
// namespace roc
52
53
#endif
// ROC_CORE_TICKER_H_
roc::core::NonCopyable
Base class for non-copyable objects.
Definition:
noncopyable.h:23
roc::core::Ticker
Ticker.
Definition:
ticker.h:23
roc::core::Ticker::wait
void wait(ticks_t ticks)
Wait until the given number of ticks elapses since start. If ticker is not started yet,...
roc::core::Ticker::elapsed
ticks_t elapsed()
Returns number of ticks elapsed since start. If ticker is not started yet, it is started automaticall...
roc::core::Ticker::start
void start()
Start ticker.
roc::core::Ticker::ticks_t
uint64_t ticks_t
Number of ticks.
Definition:
ticker.h:26
roc::core::Ticker::Ticker
Ticker(ticks_t freq)
Initialize.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition:
time.h:58
roc
Root namespace.
noncopyable.h
Non-copyable object.
panic.h
Panic.
time.h
Time definitions.
roc_core
ticker.h
Generated by
1.9.1