@@ -36,12 +36,21 @@ const namespace_oid = UUID(0x6ba7b8129dad11d180b400c04fd430c8) # 6ba7b812-9dad-
36
36
const namespace_x500 = UUID (0x6ba7b8149dad11d180b400c04fd430c8 ) # 6ba7b814-9dad-11d1-80b4-00c04fd430c8
37
37
38
38
"""
39
- uuid1([rng::AbstractRNG=GLOBAL_RNG ]) -> UUID
39
+ uuid1([rng::AbstractRNG]) -> UUID
40
40
41
41
Generates a version 1 (time-based) universally unique identifier (UUID), as specified
42
42
by RFC 4122. Note that the Node ID is randomly generated (does not identify the host)
43
43
according to section 4.5 of the RFC.
44
44
45
+ The default rng used by `uuid1` is not `GLOBAL_RNG` and every invocation of `uuid1()` without
46
+ an argument should be expected to return a unique identifier. Importantly, the outputs of
47
+ `uuid1` do not repeat even when `Random.seed!(seed)` is called. Currently (as of Julia 1.6),
48
+ `uuid1` uses `Random.RandomDevice` as the default rng. However, this is an implementation
49
+ detail that may change in the future.
50
+
51
+ !!! compat "Julia 1.6"
52
+ The output of `uuid1` does not depend on `GLOBAL_RNG` as of Julia 1.6.
53
+
45
54
# Examples
46
55
```jldoctest; filter = r"[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}"
47
56
julia> rng = MersenneTwister(1234);
@@ -50,7 +59,7 @@ julia> uuid1(rng)
50
59
UUID("cfc395e8-590f-11e8-1f13-43a2532b2fa8")
51
60
```
52
61
"""
53
- function uuid1 (rng:: AbstractRNG = Random. default_rng ())
62
+ function uuid1 (rng:: AbstractRNG = Random. RandomDevice ())
54
63
u = rand (rng, UInt128)
55
64
56
65
# mask off clock sequence and node
@@ -74,11 +83,20 @@ function uuid1(rng::AbstractRNG=Random.default_rng())
74
83
end
75
84
76
85
"""
77
- uuid4([rng::AbstractRNG=GLOBAL_RNG ]) -> UUID
86
+ uuid4([rng::AbstractRNG]) -> UUID
78
87
79
88
Generates a version 4 (random or pseudo-random) universally unique identifier (UUID),
80
89
as specified by RFC 4122.
81
90
91
+ The default rng used by `uuid4` is not `GLOBAL_RNG` and every invocation of `uuid4()` without
92
+ an argument should be expected to return a unique identifier. Importantly, the outputs of
93
+ `uuid4` do not repeat even when `Random.seed!(seed)` is called. Currently (as of Julia 1.6),
94
+ `uuid4` uses `Random.RandomDevice` as the default rng. However, this is an implementation
95
+ detail that may change in the future.
96
+
97
+ !!! compat "Julia 1.6"
98
+ The output of `uuid4` does not depend on `GLOBAL_RNG` as of Julia 1.6.
99
+
82
100
# Examples
83
101
```jldoctest
84
102
julia> rng = MersenneTwister(1234);
@@ -87,7 +105,7 @@ julia> uuid4(rng)
87
105
UUID("196f2941-2d58-45ba-9f13-43a2532b2fa8")
88
106
```
89
107
"""
90
- function uuid4 (rng:: AbstractRNG = Random. default_rng ())
108
+ function uuid4 (rng:: AbstractRNG = Random. RandomDevice ())
91
109
u = rand (rng, UInt128)
92
110
u &= 0xffffffffffff0fff3fffffffffffffff
93
111
u |= 0x00000000000040008000000000000000
0 commit comments