blob: 30496bdd5f31d9363fd3014b3f15728521a46499 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#pragma once
#include <library/cpp/deprecated/atomic/atomic.h>
#include <util/random/mersenne.h>
#include <type_traits>
namespace NYql {
class TRandGuid {
public:
TRandGuid();
TRandGuid(TRandGuid&&) = default;
TRandGuid& operator=(TRandGuid&&) = default;
void ResetSeed();
TString GenGuid();
ui64 GenNumber();
private:
TMersenne<ui64>& GetRnd() {
return reinterpret_cast<TMersenne<ui64>&>(Rnd_);
}
private:
std::aligned_storage<sizeof(TMersenne<ui64>) ,alignof(TMersenne<ui64>)>::type Rnd_;
static TAtomic Counter;
};
}
|