LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Types | Private Attributes | Friends
LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState Class Reference

Keeps state needed by the random number generator, protected by a mutex. More...

List of all members.

Public Member Functions

 RandomState ()
void reset ()
uint64_t random64 ()

Private Types

enum  { STATE_BYTES }
 Size of 'statebuf'. More...

Private Attributes

std::mutex mutex
 Protect following members from concurrent access.
bool init
 Set to true when the constructor completes.
char statebuf [STATE_BYTES]
 Internal scratch state used by random_r.
random_data randbuf
 random_r's state.

Friends

void LogCabin::Core::Random::acquireMutex ()
void LogCabin::Core::Random::releaseMutex ()

Detailed Description

Keeps state needed by the random number generator, protected by a mutex.

Definition at line 51 of file Random.cc.


Member Enumeration Documentation

anonymous enum [private]

Size of 'statebuf'.

128 is the same size as initstate() uses for regular random(), see manpages for details.

Enumerator:
STATE_BYTES 

Definition at line 136 of file Random.cc.


Constructor & Destructor Documentation

LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::RandomState ( ) [inline]

Definition at line 53 of file Random.cc.


Member Function Documentation

void LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::reset ( ) [inline]

Definition at line 74 of file Random.cc.

uint64_t LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::random64 ( ) [inline]

Definition at line 96 of file Random.cc.


Friends And Related Function Documentation


Member Data Documentation

std::mutex LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::mutex [private]

Protect following members from concurrent access.

Definition at line 125 of file Random.cc.

bool LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::init [private]

Set to true when the constructor completes.

Definition at line 130 of file Random.cc.

char LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::statebuf[STATE_BYTES] [private]

Internal scratch state used by random_r.

Definition at line 141 of file Random.cc.

random_data LogCabin::Core::Random::anonymous_namespace{Random.cc}::RandomState::randbuf [private]

random_r's state.

Must be handed to each call, and seems to refer to statebuf in some undocumented way.

Definition at line 147 of file Random.cc.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines