Prepare system extension support

This commit is contained in:
世界
2023-07-24 20:08:02 +08:00
parent 8a5c1a80d1
commit 12bf02070e
44 changed files with 1469 additions and 382 deletions
@@ -0,0 +1,23 @@
import Foundation
import Libbox
import NetworkExtension
func runBlocking<T>(_ body: @escaping () async throws -> T) throws -> T {
let semaphore = DispatchSemaphore(value: 0)
let box = resultBox<T>()
Task {
do {
let value = try await body()
box.result = .success(value)
} catch {
box.result = .failure(error)
}
semaphore.signal()
}
semaphore.wait()
return try box.result.get()
}
private class resultBox<T> {
var result: Result<T, Error>!
}