Give DatabaseTable an RSDatabaseQueue.

This commit is contained in:
Brent Simmons 2017-07-29 12:13:38 -07:00
parent 02174012ec
commit da9a974dff
6 changed files with 23 additions and 11 deletions

View File

@ -12,10 +12,12 @@ import Data
final class ArticlesTable: DatabaseTable {
let name: String
let queue: RSDatabaseQueue
init(name: String) {
init(name: String, queue: RSDatabaseQueue) {
self.name = name
self.queue = queue
}
private let cachedArticles: NSMapTable<NSString, Article> = NSMapTable.weakToWeakObjects()

View File

@ -32,9 +32,12 @@ import Data
final class AttachmentsTable: DatabaseTable {
let name: String
let queue: RSDatabaseQueue
init(name: String, queue: RSDatabaseQueue) {
init(name: String) {
self.name = name
self.queue = queue
}
private var cachedAttachments = [String: Attachment]() // Attachment.databaseID key

View File

@ -12,10 +12,12 @@ import Data
final class AuthorsTable: DatabaseTable {
let name: String
let queue: RSDatabaseQueue
init(name: String) {
init(name: String, queue: RSDatabaseQueue) {
self.name = name
self.queue = queue
}
var cachedAuthors = [String: Author]()

View File

@ -16,12 +16,14 @@ final class StatusesTable: DatabaseTable {
var cachedStatuses = [String: ArticleStatus]()
let name: String
init(name: String) {
let queue: RSDatabaseQueue
init(name: String, queue: RSDatabaseQueue) {
self.name = name
self.queue = queue
}
func markArticles(_ articles: Set<Article>, statusKey: String, flag: Bool) {
assertNoMissingStatuses(articles)

View File

@ -19,13 +19,15 @@ typealias TagNameSet = Set<String>
final class TagsTable: DatabaseTable {
let name: String
let queue: RSDatabaseQueue
private var articleIDCache = [String: TagNameSet]() // articleID: tags
private var articleIDsWithNoTags = TagNameSet()
private var articleIDsWithNoTags = Set<String>
init(name: String) {
init(name: String, queue: RSDatabaseQueue) {
self.name = name
self.queue = queue
}
func saveTagsForArticles(_ articles: Set<Article>) {

View File

@ -10,9 +10,10 @@ import Foundation
public protocol DatabaseTable {
public var name: String {get}
var name: String {get}
var queue: RSDatabaseQueue {get}
public init(name: String)
init(name: String, queue: RSDatabaseQueue)
}
extension DatabaseTable {