File tree 3 files changed +8
-1
lines changed
Sources/RandomKit/Types/RandomGenerator
3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,12 @@ Xoroshiro.withThreadLocal { randomGenerator in
248
248
}
249
249
```
250
250
251
+ As a shortcut, you can even apply a function directly as a parameter.
252
+
253
+ ```swift
254
+ let value = Xoroshiro.withThreadLocal (Int .random )
255
+ ```
256
+
251
257
Prior to [v4.4.0](https :// github.com/nvzqz/RandomKit/releases/tag/v4.4.0),
252
258
thread safety could be achieved by instantiating a new seeded instance of a
253
259
given `RandomGenerator` type. The problem with this is that unnecessary seeding
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public struct ReseedingRandomGenerator<Base: RandomGenerator & SeedableFromRando
31
31
fileprivate var _bytesGenerated : Int = 0
32
32
33
33
/// The byte threshold indicating the maximum number of bytes that can be generated before `self` is reseeded.
34
- public let threshold : Int
34
+ public var threshold : Int
35
35
36
36
/// The base `RandomGenerator` from which to generate values.
37
37
public var base : Base
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ private func _key(for type: Any.Type) -> pthread_key_t {
73
73
} else {
74
74
var key = pthread_key_t ( )
75
75
pthread_key_create ( & key) {
76
+ // Cast required because argument is optional on some platforms (Linux) but not on others (macOS).
76
77
guard let rawPointer = ( $0 as UnsafeMutableRawPointer ? ) else {
77
78
return
78
79
}
You can’t perform that action at this time.
0 commit comments