@@ -21,28 +21,28 @@ private[zio] object UUIDGeneratorBuilder {
21
21
builder : UUIDBuilder [UUIDvX ],
22
22
): UIO [UUIDvX ] =
23
23
for {
24
- random <- random.nextLong
25
- uuid <- mutex.withPermit {
26
- for {
27
- timestamp <- clock.currentTime( TimeUnit . MILLISECONDS )
28
- modifiedState <- state.modify { currentState =>
29
- // currentTime clock may run backward
30
- val actualTimestamp = Math .max(currentState.lastUsedEpochMillis, timestamp)
31
- val sequence =
32
- if ( currentState.lastUsedEpochMillis == actualTimestamp) {
33
- currentState.sequence + 1
34
- } else 0L
35
-
36
- val newState = GeneratorState (lastUsedEpochMillis = actualTimestamp, sequence = sequence )
37
- (newState, newState)
38
- }
39
- } yield builder(
40
- modifiedState.lastUsedEpochMillis,
41
- modifiedState.sequence,
42
- random ,
43
- )
44
- }
45
- } yield uuid
24
+ modifiedState <- mutex.withPermit {
25
+ for {
26
+ timestamp <- clock.currentTime( TimeUnit . MILLISECONDS )
27
+ modifiedState <- state.modify { currentState =>
28
+ // currentTime clock may run backward
29
+ val actualTimestamp = Math .max(currentState.lastUsedEpochMillis, timestamp)
30
+ val sequence =
31
+ if (currentState.lastUsedEpochMillis == actualTimestamp) {
32
+ currentState.sequence + 1
33
+ } else 0L
34
+
35
+ val newState = GeneratorState (lastUsedEpochMillis = actualTimestamp, sequence = sequence)
36
+ (newState, newState )
37
+ }
38
+ } yield modifiedState
39
+ }
40
+ random <- random.nextLong
41
+ } yield builder(
42
+ modifiedState.lastUsedEpochMillis ,
43
+ modifiedState.sequence,
44
+ random,
45
+ )
46
46
47
47
// noinspection YieldingZIOEffectInspection
48
48
def buildGenerator [UUIDvX ](builder : UUIDBuilder [UUIDvX ]): UIO [UIO [UUIDvX ]] =
0 commit comments