mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 01:16:55 +02:00
fixed GH #2217: UUIDGenerator should allow random seed
This commit is contained in:
parent
71585b7daa
commit
2327592bab
@ -78,6 +78,13 @@ public:
|
||||
/// The UUID::version() method can be used to determine the actual kind of
|
||||
/// the UUID generated.
|
||||
|
||||
void seed(UInt32 n);
|
||||
/// Seeds the internal pseudo random generator for time-based UUIDs with the given seed.
|
||||
|
||||
void seed();
|
||||
/// Seeds the internal pseudo random generator used for time-based UUIDs
|
||||
/// with a random seed obtained from a RandomInputStream.
|
||||
|
||||
static UUIDGenerator& defaultGenerator();
|
||||
/// Returns a reference to the default UUIDGenerator.
|
||||
|
||||
|
@ -136,6 +136,22 @@ UUID UUIDGenerator::createOne()
|
||||
}
|
||||
|
||||
|
||||
void UUIDGenerator::seed()
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_random.seed();
|
||||
}
|
||||
|
||||
|
||||
void UUIDGenerator::seed(UInt32 n)
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_random.seed(n);
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
static SingletonHolder<UUIDGenerator> sh;
|
||||
|
Loading…
x
Reference in New Issue
Block a user