mirror of https://github.com/mpv-player/mpv
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:
parent
b390ade709
commit
1364c80e64
|
@ -15,6 +15,16 @@
|
||||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
* 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)
|
#if !swift(>=5.0)
|
||||||
extension Data {
|
extension Data {
|
||||||
mutating func withUnsafeMutableBytes<Type>(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type {
|
mutating func withUnsafeMutableBytes<Type>(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type {
|
||||||
|
|
Loading…
Reference in New Issue