LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Namespaces | Functions
LogCabin::Core::Random Namespace Reference

Thread-safe pseudo-random number generator. More...

Namespaces

namespace  anonymous_namespace{Random.cc}

Functions

void acquireMutex ()
 Called before fork() to grab the mutex used in pthread_atfork.
void releaseMutex ()
 Called in the parent post fork().
uint8_t random8 ()
 Return one random byte.
uint16_t random16 ()
 Return two random bytes.
uint32_t random32 ()
 Return four random bytes.
uint64_t random64 ()
 Return eight random bytes.
double randomRangeDouble (double start, double end)
 Return a random floating point number between start and end, inclusive.
uint64_t randomRange (uint64_t start, uint64_t end)
 Return a random integer between start and end, inclusive.

Detailed Description

Thread-safe pseudo-random number generator.

Warning:
Don't call these functions from static initializers or you might run into the static initialization order fiasco.

Function Documentation

Called before fork() to grab the mutex used in pthread_atfork.

This function is outside of the anonymous namespace so it can be called from RandomTest.

Definition at line 196 of file Random.cc.

Called in the parent post fork().

This function is outside of the anonymous namespace so it can be called from RandomTest.

Definition at line 206 of file Random.cc.

Return one random byte.

Definition at line 212 of file Random.cc.

Return two random bytes.

Definition at line 218 of file Random.cc.

Return four random bytes.

Definition at line 224 of file Random.cc.

Return eight random bytes.

Definition at line 230 of file Random.cc.

double LogCabin::Core::Random::randomRangeDouble ( double  start,
double  end 
)

Return a random floating point number between start and end, inclusive.

Definition at line 236 of file Random.cc.

uint64_t LogCabin::Core::Random::randomRange ( uint64_t  start,
uint64_t  end 
)

Return a random integer between start and end, inclusive.

Definition at line 242 of file Random.cc.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines