Change Reddit and Twitter feed providers to use dedicated instead of global queues for parsing

This commit is contained in:
Maurice Parker 2020-07-27 16:20:15 -05:00
parent 8e890ec177
commit e3363041ab
2 changed files with 6 additions and 2 deletions

View File

@ -48,6 +48,8 @@ public final class RedditFeedProvider: FeedProvider {
"all": NSLocalizedString("All", comment: "All")
]
private var parsingQueue = DispatchQueue(label: "RedditFeedProvider parse queue")
public var username: String?
private var oauthToken: String
@ -192,7 +194,7 @@ public final class RedditFeedProvider: FeedProvider {
fetch(api: api, parameters: [:], resultType: RedditLinkListing.self) { result in
switch result {
case .success(let linkListing):
DispatchQueue.global(qos: .background).async {
self.parsingQueue.async {
let parsedItems = self.makeParsedItems(webFeed.url, identifySubreddit, linkListing)
DispatchQueue.main.async {
completion(.success(parsedItems))

View File

@ -47,6 +47,8 @@ public final class TwitterFeedProvider: FeedProvider {
private static let userPaths = ["/home", "/notifications"]
private static let reservedPaths = ["/search", "/explore", "/messages", "/i", "/compose"]
private var parsingQueue = DispatchQueue(label: "TwitterFeedProvider parse queue")
public var screenName: String
private var oauthToken: String
@ -227,7 +229,7 @@ public final class TwitterFeedProvider: FeedProvider {
if let sinceID = statuses.first?.idStr {
webFeed.sinceToken = sinceID
}
DispatchQueue.global(qos: .background).async {
self.parsingQueue.async {
let parsedItems = self.makeParsedItems(webFeed.url, statuses)
DispatchQueue.main.async {
completion(.success(parsedItems))