![]() |
OpenMS
|
A generator for unique ids. More...
#include <OpenMS/CONCEPT/UniqueIdGenerator.h>
Static Public Member Functions | |
| static UInt64 | getUniqueId () |
| Returns a new, nonzero unique id. | |
| static std::string | getUUID () |
| Returns a new random UUID (version 4) | |
| static void | setSeed (UInt64 seed) |
| Reseed the shared generator. | |
| static UInt64 | getSeed () |
| Get the seed. | |
Protected Member Functions | |
| UniqueIdGenerator () | |
| ~UniqueIdGenerator () | |
Private Member Functions | |
| UniqueIdGenerator (const UniqueIdGenerator &) | |
A generator for unique ids.
The unique ids are nonzero 64-bit random unsigned integers. All callers share one generator with process lifetime. The random generator is std::mt19937_64 (MT19937-64), whose output sequence is fully specified by the algorithm and therefore identical on every platform and standard library. Zero engine outputs are skipped because they represent an invalid unique id. Random values can still collide; map-level uniqueness must be checked separately.
A mutex guards every draw, so generation is thread-safe with or without OpenMP. The ids are the consecutive outputs of the shared engine, except for skipped zeros: for a given seed, the ids drawn up to any point are the same set however many threads drew them. Only which thread receives which id depends on scheduling.
|
protected |
|
protected |
|
private |
|
static |
Get the seed.
|
static |
Returns a new, nonzero unique id.
|
static |
Returns a new random UUID (version 4)
Formatted as the standard 36-character string "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".
|
static |
Reseed the shared generator.
| [in] | seed | Seed for the Mersenne Twister engine. |