Additional 'afterAsync' changes for the groups branch

pull/894/head
Morgan Pretty 1 year ago
parent 28699798f1
commit 16addb3b91

@ -583,7 +583,7 @@ extension ConversationVC:
let threadId: String = self.viewModel.threadData.threadId
let threadVariant: SessionThread.Variant = self.viewModel.threadData.threadVariant
DispatchQueue.global(qos:.userInitiated).async(using: viewModel.dependencies) { [dependencies = viewModel.dependencies] in
DispatchQueue.global(qos:.userInitiated).asyncAfter(deadline: .now() + 0.01, using: viewModel.dependencies) { [dependencies = viewModel.dependencies] in
// Generate the quote thumbnail if needed (want this to happen outside of the DBWrite thread as
// this can take up to 0.5s
let quoteThumbnailAttachment: Attachment? = optimisticData.quoteModel?.attachment?

@ -648,7 +648,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa
// PagedDatabaseObserver won't have them so we need to force a re-fetch of the current
// data to ensure everything is up to date
if didReturnFromBackground {
DispatchQueue.global(qos: .background).async {
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 0.01) {
self?.viewModel.pagedDataObserver?.reload()
}
}

@ -257,7 +257,7 @@ public class ConversationViewModel: OWSAudioPlayerDelegate, NavigatableStateHold
)
// Run the initial query on a background thread so we don't block the push transition
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
DispatchQueue.global(qos: .userInitiated).asyncAfter(deadline: .now() + 0.01) { [weak self] in
// If we don't have a `initialFocusedInfo` then default to `.pageBefore` (it'll query
// from a `0` offset)
switch (focusedInteractionInfo ?? initialData?.initialUnreadInteractionInfo) {

@ -257,7 +257,7 @@ class GlobalSearchViewController: BaseVC, LibSessionRespondingViewController, UI
lastSearchText = searchText
DispatchQueue.global(qos: .default).async { [weak self, dependencies] in
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + 0.01) { [weak self, dependencies] in
self?.readConnection?.interrupt()
let result: Result<[SectionModel], Error>? = dependencies[singleton: .storage].read { db -> Result<[SectionModel], Error> in

@ -102,7 +102,9 @@ public extension GroupPoller {
.asRequest(of: String.self)
.fetchSet(db)
}?
.forEach { [weak self] swarmPublicKey in self?.getOrCreatePoller(for: swarmPublicKey).startIfNeeded() }
.forEach { [weak self] swarmPublicKey in
self?.getOrCreatePoller(for: swarmPublicKey).startIfNeeded()
}
}
}

@ -774,7 +774,7 @@ public extension LibSession {
/// **Note:** We do it this way because `DispatchQueue.async` can be optimised out if the code is already running in a
/// queue with the same `qos`, this approach ensures the code will run in a subsequent run loop regardless
let concurrentQueue = DispatchQueue(label: "Network.callback.registration", attributes: .concurrent)
concurrentQueue.async(flags: .barrier) { [weak self] in
concurrentQueue.asyncAfter(deadline: .now() + 0.01, flags: .barrier) { [weak self] in
guard
let network: UnsafeMutablePointer<network_object> = self?.network,
let dependenciesPtr: UnsafeMutableRawPointer = self?.dependenciesPtr
@ -789,7 +789,7 @@ public extension LibSession {
// Dispatch async so we don't hold up the libSession thread that triggered the update
// or have a reentrancy issue with the mutable cache
DispatchQueue.global(qos: .default).async {
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + 0.01) {
dependencies.mutate(cache: .libSessionNetwork) { $0.setNetworkStatus(status: status) }
}
}, dependenciesPtr)
@ -829,7 +829,7 @@ public extension LibSession {
// or have a reentrancy issue with the mutable cache
let dependencies: Dependencies = Unmanaged<Dependencies>.fromOpaque(ctx).takeUnretainedValue()
DispatchQueue.global(qos: .default).async {
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + 0.01) {
dependencies.mutate(cache: .libSessionNetwork) { $0.setPaths(paths: paths) }
}
}, dependenciesPtr)

@ -1416,7 +1416,7 @@ public final class JobQueue: Hashable {
// Ensure this is running on the correct queue
guard DispatchQueue.with(key: queueKey, matches: queueContext, using: dependencies) else {
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
return
@ -1552,7 +1552,7 @@ public final class JobQueue: Hashable {
// If this queue executes concurrently and there are still jobs remaining then immediately attempt
// to start the next job
if executionType == .concurrent && numJobsRemaining > 0 {
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
}
@ -1600,7 +1600,7 @@ public final class JobQueue: Hashable {
// Trigger the 'start' function to load in any pending jobs that aren't already in the
// queue (for concurrent queues we want to force them to load in pending jobs and add
// them to the queue regardless of whether the queue is already running)
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.start(forceWhenAlreadyRunning: (self?.executionType == .concurrent))
}
return
@ -1692,7 +1692,7 @@ public final class JobQueue: Hashable {
// Perform job cleanup and start the next job
performCleanUp(for: job, result: .succeeded)
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
}
@ -1708,7 +1708,7 @@ public final class JobQueue: Hashable {
Log.info(.jobRunner, "\(queueContext) \(job) canceled")
performCleanUp(for: job, result: .failed(error, permanentFailure))
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
return
@ -1734,7 +1734,7 @@ public final class JobQueue: Hashable {
_pendingJobsQueue.performUpdate { $0.inserting(job, at: 0) }
}
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
return
@ -1806,7 +1806,7 @@ public final class JobQueue: Hashable {
Log.error(.jobRunner, "\(queueContext) \(job) \(failureText)")
performCleanUp(for: job, result: .failed(error, permanentFailure))
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
}
@ -1859,7 +1859,7 @@ public final class JobQueue: Hashable {
}
performCleanUp(for: job, result: .deferred)
internalQueue.async(using: dependencies) { [weak self] in
internalQueue.asyncAfter(deadline: .now() + 0.01, using: dependencies) { [weak self] in
self?.runNextJob()
}
}

Loading…
Cancel
Save