mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-04 02:46:35 -06:00
- Combines all .entitlements into either: App-iOS, App-catalyst, WatchApp, Extension-iOS or Extension-catalyst. - Cleans up and renames all the schemes to match target names - Moves around several folders and deletes some old files. - Converts Podfile to be hierarchical, rather than calling shared methods. - Always runs MaterialDesignIcons script; aborts early if it's up-to-date. - Updates all dependencies.
38 lines
1.2 KiB
Swift
38 lines
1.2 KiB
Swift
import Foundation
|
|
import PromiseKit
|
|
|
|
public class ProcessInfoBackgroundTaskRunner: HomeAssistantBackgroundTaskRunner {
|
|
public func callAsFunction<PromiseValue>(
|
|
withName name: String,
|
|
wrapping: (TimeInterval?) -> Promise<PromiseValue>
|
|
) -> Promise<PromiseValue> {
|
|
ProcessInfo.processInfo.backgroundTask(withName: name, wrapping: wrapping)
|
|
}
|
|
}
|
|
|
|
private extension ProcessInfo {
|
|
func backgroundTask<PromiseValue>(
|
|
withName name: String,
|
|
wrapping: (TimeInterval?) -> Promise<PromiseValue>
|
|
) -> Promise<PromiseValue> {
|
|
let identifier = UUID()
|
|
let semaphore = DispatchSemaphore(value: 0)
|
|
|
|
return HomeAssistantBackgroundTask.execute(
|
|
withName: name,
|
|
beginBackgroundTask: { name, expirationHandler -> (UUID?, TimeInterval?) in
|
|
performExpiringActivity(withReason: name) { expire in
|
|
if expire {
|
|
expirationHandler()
|
|
} else {
|
|
semaphore.wait()
|
|
}
|
|
}
|
|
return (identifier, nil)
|
|
}, endBackgroundTask: { _ in
|
|
semaphore.signal()
|
|
}, wrapping: wrapping
|
|
)
|
|
}
|
|
}
|