mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-23 19:30:20 +00:00
mac/compat: add withLock fallback for xcode older than 14
withLock is available for macOS versions starting from 10.10 but can only be used on xcode 14+. xcode 14 introduced swift 5.7, so we guard it behind a swift version check.
This commit is contained in:
@@ -15,6 +15,16 @@
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !swift(>=5.7)
|
||||
extension NSCondition {
|
||||
func withLock<R>(_ body: () throws -> R) rethrows -> R {
|
||||
self.lock()
|
||||
defer { self.unlock() }
|
||||
return try body()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !swift(>=5.0)
|
||||
extension Data {
|
||||
mutating func withUnsafeMutableBytes<Type>(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type {
|
||||
|
||||
Reference in New Issue
Block a user