mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
fixed GH #2217: UUIDGenerator should allow random seed
This commit is contained in:
@@ -78,6 +78,13 @@ public:
|
|||||||
/// The UUID::version() method can be used to determine the actual kind of
|
/// The UUID::version() method can be used to determine the actual kind of
|
||||||
/// the UUID generated.
|
/// 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();
|
static UUIDGenerator& defaultGenerator();
|
||||||
/// Returns a reference to the default UUIDGenerator.
|
/// 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
|
namespace
|
||||||
{
|
{
|
||||||
static SingletonHolder<UUIDGenerator> sh;
|
static SingletonHolder<UUIDGenerator> sh;
|
||||||
|
|||||||
Reference in New Issue
Block a user