Skip to content

Commit 987b1b5

Browse files
committed
don't accidentally make the locks public
1 parent e4e7b41 commit 987b1b5

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

Sources/Prometheus/NIOLock.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ extension LockStorage: Sendable {}
216216
/// of lock is safe to use with `libpthread`-based threading models, such as the
217217
/// one used by NIO. On Windows, the lock is based on the substantially similar
218218
/// `SRWLOCK` type.
219-
public struct NIOLock {
219+
struct NIOLock {
220220
@usableFromInline
221221
internal let _storage: LockStorage<Void>
222222

223223
/// Create a new lock.
224224
@inlinable
225-
public init() {
225+
init() {
226226
self._storage = .create(value: ())
227227
}
228228

@@ -231,7 +231,7 @@ public struct NIOLock {
231231
/// Whenever possible, consider using `withLock` instead of this method and
232232
/// `unlock`, to simplify lock handling.
233233
@inlinable
234-
public func lock() {
234+
func lock() {
235235
self._storage.lock()
236236
}
237237

@@ -240,7 +240,7 @@ public struct NIOLock {
240240
/// Whenever possible, consider using `withLock` instead of this method and
241241
/// `lock`, to simplify lock handling.
242242
@inlinable
243-
public func unlock() {
243+
func unlock() {
244244
self._storage.unlock()
245245
}
246246

@@ -260,7 +260,7 @@ extension NIOLock {
260260
/// - Parameter body: The block to execute while holding the lock.
261261
/// - Returns: The value returned by the block.
262262
@inlinable
263-
public func withLock<T>(_ body: () throws -> T) rethrows -> T {
263+
func withLock<T>(_ body: () throws -> T) rethrows -> T {
264264
self.lock()
265265
defer {
266266
self.unlock()
@@ -269,7 +269,7 @@ extension NIOLock {
269269
}
270270

271271
@inlinable
272-
public func withLockVoid(_ body: () throws -> Void) rethrows {
272+
func withLockVoid(_ body: () throws -> Void) rethrows {
273273
try self.withLock(body)
274274
}
275275
}

Sources/Prometheus/NIOLockedValueBox.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@
3434
/// accesses to a value using the lock. But it's easy to forget to actually
3535
/// acquire/release the lock in the correct place. ``NIOLockedValueBox`` makes
3636
/// that much easier.
37-
public struct NIOLockedValueBox<Value> {
37+
@usableFromInline
38+
struct NIOLockedValueBox<Value> {
3839

3940
@usableFromInline
4041
internal let _storage: LockStorage<Value>
4142

4243
/// Initialize the `Value`.
4344
@inlinable
44-
public init(_ value: Value) {
45+
init(_ value: Value) {
4546
self._storage = .create(value: value)
4647
}
4748

4849
/// Access the `Value`, allowing mutation of it.
4950
@inlinable
50-
public func withLockedValue<T>(_ mutate: (inout Value) throws -> T) rethrows -> T {
51+
func withLockedValue<T>(_ mutate: (inout Value) throws -> T) rethrows -> T {
5152
try self._storage.withLockedValue(mutate)
5253
}
5354

@@ -56,24 +57,24 @@ public struct NIOLockedValueBox<Value> {
5657
/// This can be beneficial when you require fine grained control over the lock in some
5758
/// situations but don't want lose the benefits of ``withLockedValue(_:)`` in others by
5859
/// switching to ``NIOLock``.
59-
public var unsafe: Unsafe {
60+
var unsafe: Unsafe {
6061
Unsafe(_storage: self._storage)
6162
}
6263

6364
/// Provides an unsafe view over the lock and its value.
64-
public struct Unsafe {
65+
struct Unsafe {
6566
@usableFromInline
6667
let _storage: LockStorage<Value>
6768

6869
/// Manually acquire the lock.
6970
@inlinable
70-
public func lock() {
71+
func lock() {
7172
self._storage.lock()
7273
}
7374

7475
/// Manually release the lock.
7576
@inlinable
76-
public func unlock() {
77+
func unlock() {
7778
self._storage.unlock()
7879
}
7980

@@ -82,7 +83,7 @@ public struct NIOLockedValueBox<Value> {
8283
/// - Parameter mutate: A closure with scoped access to the value.
8384
/// - Returns: The result of the `mutate` closure.
8485
@inlinable
85-
public func withValueAssumingLockIsAcquired<Result>(
86+
func withValueAssumingLockIsAcquired<Result>(
8687
_ mutate: (_ value: inout Value) throws -> Result
8788
) rethrows -> Result {
8889
try self._storage.withUnsafeMutablePointerToHeader { value in

0 commit comments

Comments
 (0)