Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
time.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Roc 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/time.h
10 //! @brief Time definitions.
11 
12 #ifndef ROC_CORE_TIME_H_
13 #define ROC_CORE_TIME_H_
14 
15 #include "roc_core/stddefs.h"
16 
17 namespace roc {
18 namespace core {
19 
20 //! Nanoseconds.
21 typedef int64_t nanoseconds_t;
22 
23 //! One nanosecond represented in nanoseconds.
24 const nanoseconds_t Nanosecond = 1;
25 
26 //! One microsecond represented in nanoseconds.
27 const nanoseconds_t Microsecond = 1000 * Nanosecond;
28 
29 //! One millisecond represented in nanoseconds.
30 const nanoseconds_t Millisecond = 1000 * Microsecond;
31 
32 //! One second represented in nanoseconds.
33 const nanoseconds_t Second = 1000 * Millisecond;
34 
35 //! One minute represented in nanoseconds.
36 const nanoseconds_t Minute = 60 * Second;
37 
38 //! One hour represented in nanoseconds.
39 const nanoseconds_t Hour = 60 * Minute;
40 
41 //! Get current timestamp in nanoseconds.
42 nanoseconds_t timestamp();
43 
44 //! Sleep until the specified absolute time point has been reached.
45 //! @remarks
46 //! @p timestamp specifies absolute time point in nanoseconds.
47 void sleep_until(nanoseconds_t timestamp);
48 
49 //! Sleep specified amount of time.
50 //! @remarks
51 //! @p duration specifies number of nanoseconds to sleep.
52 void sleep_for(nanoseconds_t duration);
53 
54 } // namespace core
55 } // namespace roc
56 
57 #endif // ROC_CORE_TIME_H_
const nanoseconds_t Millisecond
One millisecond represented in nanoseconds.
Definition: time.h:30
const nanoseconds_t Minute
One minute represented in nanoseconds.
Definition: time.h:36
Root namespace.
const nanoseconds_t Microsecond
One microsecond represented in nanoseconds.
Definition: time.h:27
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:21
void sleep_until(nanoseconds_t timestamp)
Sleep until the specified absolute time point has been reached.
Commonly used types and functions.
const nanoseconds_t Nanosecond
One nanosecond represented in nanoseconds.
Definition: time.h:24
void sleep_for(nanoseconds_t duration)
Sleep specified amount of time.
const nanoseconds_t Hour
One hour represented in nanoseconds.
Definition: time.h:39
const nanoseconds_t Second
One second represented in nanoseconds.
Definition: time.h:33
nanoseconds_t timestamp()
Get current timestamp in nanoseconds.