@@ -46,21 +46,16 @@ import wasi_pthread
46
46
#endif
47
47
48
48
#if os(Windows)
49
- @usableFromInline
50
49
typealias LockPrimitive = SRWLOCK
51
50
#elseif canImport(Darwin)
52
- @usableFromInline
53
51
typealias LockPrimitive = os_unfair_lock
54
52
#else
55
- @usableFromInline
56
53
typealias LockPrimitive = pthread_mutex_t
57
54
#endif
58
55
59
- @usableFromInline
60
56
enum LockOperations { }
61
57
62
58
extension LockOperations {
63
- @inlinable
64
59
static func create( _ mutex: UnsafeMutablePointer < LockPrimitive > ) {
65
60
mutex. assertValidAlignment ( )
66
61
@@ -77,7 +72,6 @@ extension LockOperations {
77
72
#endif
78
73
}
79
74
80
- @inlinable
81
75
static func destroy( _ mutex: UnsafeMutablePointer < LockPrimitive > ) {
82
76
mutex. assertValidAlignment ( )
83
77
@@ -91,7 +85,6 @@ extension LockOperations {
91
85
#endif
92
86
}
93
87
94
- @inlinable
95
88
static func lock( _ mutex: UnsafeMutablePointer < LockPrimitive > ) {
96
89
mutex. assertValidAlignment ( )
97
90
@@ -105,7 +98,6 @@ extension LockOperations {
105
98
#endif
106
99
}
107
100
108
- @inlinable
109
101
static func unlock( _ mutex: UnsafeMutablePointer < LockPrimitive > ) {
110
102
mutex. assertValidAlignment ( )
111
103
@@ -148,10 +140,8 @@ extension LockOperations {
148
140
// and future maintainers will be happier that we were cautious.
149
141
//
150
142
// See also: https://github.com/apple/swift/pull/40000
151
- @usableFromInline
152
143
final class LockStorage < Value> : ManagedBuffer < Value , LockPrimitive > {
153
144
154
- @inlinable
155
145
static func create( value: Value ) -> Self {
156
146
let buffer = Self . create ( minimumCapacity: 1 ) { _ in
157
147
value
@@ -168,35 +158,30 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
168
158
return storage
169
159
}
170
160
171
- @inlinable
172
161
func lock( ) {
173
162
self . withUnsafeMutablePointerToElements { lockPtr in
174
163
LockOperations . lock ( lockPtr)
175
164
}
176
165
}
177
166
178
- @inlinable
179
167
func unlock( ) {
180
168
self . withUnsafeMutablePointerToElements { lockPtr in
181
169
LockOperations . unlock ( lockPtr)
182
170
}
183
171
}
184
172
185
- @inlinable
186
173
deinit {
187
174
self . withUnsafeMutablePointerToElements { lockPtr in
188
175
LockOperations . destroy ( lockPtr)
189
176
}
190
177
}
191
178
192
- @inlinable
193
179
func withLockPrimitive< T> ( _ body: ( UnsafeMutablePointer < LockPrimitive > ) throws -> T ) rethrows -> T {
194
180
try self . withUnsafeMutablePointerToElements { lockPtr in
195
181
try body ( lockPtr)
196
182
}
197
183
}
198
184
199
- @inlinable
200
185
func withLockedValue< T> ( _ mutate: ( inout Value ) throws -> T ) rethrows -> T {
201
186
try self . withUnsafeMutablePointers { valuePtr, lockPtr in
202
187
LockOperations . lock ( lockPtr)
@@ -209,7 +194,6 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
209
194
extension LockStorage : @unchecked Sendable { }
210
195
211
196
extension UnsafeMutablePointer {
212
- @inlinable
213
197
func assertValidAlignment( ) {
214
198
assert ( UInt ( bitPattern: self ) % UInt( MemoryLayout< Pointee> . alignment) == 0 )
215
199
}
0 commit comments