Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
fast_random.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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/fast_random.h
10 //! @brief Helpers to work with random numbers.
11 
12 #ifndef ROC_CORE_FAST_RANDOM_H_
13 #define ROC_CORE_FAST_RANDOM_H_
14 
15 #include "roc_core/stddefs.h"
16 
17 namespace roc {
18 namespace core {
19 
20 //! Get a random integer from a non cryptographically secure, but fast PRNG.
21 //! Thread-safe.
22 //! @returns random value in range [from; to].
23 uint32_t fast_random_range(uint32_t from, uint32_t to);
24 
25 //! Get a random integer from a non cryptographically secure, but fast PRNG.
26 //! Thread-safe.
27 //! @returns random value between 0 and UINT32_MAX.
28 uint32_t fast_random();
29 
30 } // namespace core
31 } // namespace roc
32 
33 #endif // ROC_CORE_FAST_RANDOM_H_
uint32_t fast_random()
Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe.
uint32_t fast_random_range(uint32_t from, uint32_t to)
Get a random integer from a non cryptographically secure, but fast PRNG. Thread-safe.
Root namespace.
Commonly used types and functions.