mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
Cleaned up the Dependencies so that tests can run synchronously without having to custom set queues as much Sorted out the crypto and network dependencies to avoid needing weird dependency inheritance Fixed the flaky tests so they are no longer flaky Fixed some unexpected JobRunner behaviours Updated the CI config to use a local build directory for derivedData (now works with build tweaks)
36 lines
1.2 KiB
Swift
36 lines
1.2 KiB
Swift
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public extension DispatchQueue {
|
|
func async(
|
|
group: DispatchGroup? = nil,
|
|
qos: DispatchQoS = .unspecified,
|
|
flags: DispatchWorkItemFlags = [],
|
|
using dependencies: Dependencies,
|
|
execute work: @escaping () -> Void
|
|
) {
|
|
guard !dependencies.forceSynchronous else { return work() }
|
|
|
|
return self.async(group: group, qos: qos, flags: flags, execute: work)
|
|
}
|
|
|
|
func asyncAfter(
|
|
deadline: DispatchTime,
|
|
qos: DispatchQoS = .unspecified,
|
|
flags: DispatchWorkItemFlags = [],
|
|
using dependencies: Dependencies,
|
|
execute work: @escaping () -> Void
|
|
) {
|
|
guard !dependencies.forceSynchronous else { return work() }
|
|
|
|
self.asyncAfter(deadline: deadline, qos: qos, flags: flags, execute: work)
|
|
}
|
|
|
|
static func with(key: DispatchSpecificKey<String>, matches context: String, using dependencies: Dependencies) -> Bool {
|
|
guard !dependencies.forceSynchronous else { return true }
|
|
|
|
return (DispatchQueue.getSpecific(key: key) == context)
|
|
}
|
|
}
|