|
22 | 22 |
|
23 | 23 | public final class Lock: Locking { |
24 | 24 |
|
25 | | - private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1) |
| 25 | + private var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1) |
26 | 26 |
|
27 | 27 | public init() { |
28 | 28 | pthread_mutex_init(mutex, nil) |
|
31 | 31 | deinit { |
32 | 32 | pthread_mutex_destroy(mutex) |
33 | 33 | mutex.deinitialize() |
34 | | - mutex.deallocateCapacity(1) |
| 34 | + mutex.deallocate(capacity: 1) |
35 | 35 | } |
36 | 36 |
|
37 | 37 | public func lock() { |
|
131 | 131 | } |
132 | 132 |
|
133 | 133 | public final class RecursiveLock: Locking { |
134 | | - private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1) |
| 134 | + private var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1) |
135 | 135 |
|
136 | 136 | public init() { |
137 | 137 |
|
|
145 | 145 | deinit { |
146 | 146 | pthread_mutex_destroy(mutex) |
147 | 147 | mutex.deinitialize() |
148 | | - mutex.deallocateCapacity(1) |
| 148 | + mutex.deallocate(capacity: 1) |
149 | 149 | } |
150 | 150 |
|
151 | 151 | public func lock() { |
|
164 | 164 | } |
165 | 165 |
|
166 | 166 | public final class Condition: Locking { |
167 | | - private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1) |
168 | | - private var cond = UnsafeMutablePointer<pthread_cond_t>(allocatingCapacity: 1) |
| 167 | + private var mutex = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1) |
| 168 | + private var cond = UnsafeMutablePointer<pthread_cond_t>.allocate(capacity: 1) |
169 | 169 |
|
170 | 170 | public init() { |
171 | 171 | pthread_mutex_init(mutex, nil) |
|
177 | 177 | pthread_cond_destroy(cond) |
178 | 178 | mutex.deinitialize() |
179 | 179 | cond.deinitialize() |
180 | | - mutex.deallocateCapacity(1) |
181 | | - cond.deallocateCapacity(1) |
| 180 | + mutex.deallocate(capacity: 1) |
| 181 | + cond.deallocate(capacity: 1) |
182 | 182 | } |
183 | 183 |
|
184 | 184 | public func lock() { |
|
0 commit comments