Change Reddit and Twitter feed providers to use dedicated instead of global queues for parsing
This commit is contained in:
parent
8e890ec177
commit
e3363041ab
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue