File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed
Sources/RandomKit/Types/RandomGenerator Expand file tree Collapse file tree 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
248248}
249249```
250250
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+
251257Prior to [v4.4.0](https :// github.com/nvzqz/RandomKit/releases/tag/v4.4.0),
252258thread safety could be achieved by instantiating a new seeded instance of a
253259given `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
3131 fileprivate var _bytesGenerated : Int = 0
3232
3333 /// 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
3535
3636 /// The base `RandomGenerator` from which to generate values.
3737 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 {
7373 } else {
7474 var key = pthread_key_t ( )
7575 pthread_key_create ( & key) {
76+ // Cast required because argument is optional on some platforms (Linux) but not on others (macOS).
7677 guard let rawPointer = ( $0 as UnsafeMutableRawPointer ? ) else {
7778 return
7879 }
You can’t perform that action at this time.
0 commit comments