34
34
/// accesses to a value using the lock. But it's easy to forget to actually
35
35
/// acquire/release the lock in the correct place. ``NIOLockedValueBox`` makes
36
36
/// that much easier.
37
- public struct NIOLockedValueBox < Value> {
37
+ @usableFromInline
38
+ struct NIOLockedValueBox < Value> {
38
39
39
40
@usableFromInline
40
41
internal let _storage : LockStorage < Value >
41
42
42
43
/// Initialize the `Value`.
43
44
@inlinable
44
- public init ( _ value: Value ) {
45
+ init ( _ value: Value ) {
45
46
self . _storage = . create( value: value)
46
47
}
47
48
48
49
/// Access the `Value`, allowing mutation of it.
49
50
@inlinable
50
- public func withLockedValue< T> ( _ mutate: ( inout Value ) throws -> T ) rethrows -> T {
51
+ func withLockedValue< T> ( _ mutate: ( inout Value ) throws -> T ) rethrows -> T {
51
52
try self . _storage. withLockedValue ( mutate)
52
53
}
53
54
@@ -56,24 +57,24 @@ public struct NIOLockedValueBox<Value> {
56
57
/// This can be beneficial when you require fine grained control over the lock in some
57
58
/// situations but don't want lose the benefits of ``withLockedValue(_:)`` in others by
58
59
/// switching to ``NIOLock``.
59
- public var unsafe : Unsafe {
60
+ var unsafe : Unsafe {
60
61
Unsafe ( _storage: self . _storage)
61
62
}
62
63
63
64
/// Provides an unsafe view over the lock and its value.
64
- public struct Unsafe {
65
+ struct Unsafe {
65
66
@usableFromInline
66
67
let _storage : LockStorage < Value >
67
68
68
69
/// Manually acquire the lock.
69
70
@inlinable
70
- public func lock( ) {
71
+ func lock( ) {
71
72
self . _storage. lock ( )
72
73
}
73
74
74
75
/// Manually release the lock.
75
76
@inlinable
76
- public func unlock( ) {
77
+ func unlock( ) {
77
78
self . _storage. unlock ( )
78
79
}
79
80
@@ -82,7 +83,7 @@ public struct NIOLockedValueBox<Value> {
82
83
/// - Parameter mutate: A closure with scoped access to the value.
83
84
/// - Returns: The result of the `mutate` closure.
84
85
@inlinable
85
- public func withValueAssumingLockIsAcquired< Result> (
86
+ func withValueAssumingLockIsAcquired< Result> (
86
87
_ mutate: ( _ value: inout Value ) throws -> Result
87
88
) rethrows -> Result {
88
89
try self . _storage. withUnsafeMutablePointerToHeader { value in
0 commit comments