Skip to content

Commit b8cdd50

Browse files
committed
Merge branch 'master' into 5.x
2 parents ed9bbf6 + f1258a0 commit b8cdd50

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
251257
Prior to [v4.4.0](https://github.com/nvzqz/RandomKit/releases/tag/v4.4.0),
252258
thread safety could be achieved by instantiating a new seeded instance of a
253259
given `RandomGenerator` type. The problem with this is that unnecessary seeding

Sources/RandomKit/Types/RandomGenerator/ReseedingRandomGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

Sources/RandomKit/Types/RandomGenerator/ThreadLocal.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)