thisRealm is the synchronized MongoDB I got from asyncOpen.
let rc = thisRealm.configuration
let rq = DispatchQueue(label: “readQueue”, qos: .userInteractive, autoreleaseFrequency: .workItem)
let readRealm: RealmSwift.Realm // not defined yet.
rq.sync {
readRealm = try! Realm(configuration: rc, queue: rq)
}
In the Xcode quick help
Parameters
configuration
A configuration value to use when creating the Realm.
queue
An optional dispatch queue to confine the Realm to. If given, this Realm instance can be used from within blocks dispatched to the given queue rather than on the current thread.
I’m confused:
- On one hand, the documentation in this Quick Help seems to indicate that I can create one realm and use it in any block dispatched to that queue.
- On the other hand, according to Apple, serial dispatch queues are not guaranteed to use the same thread each time they are used.
Am I tempting Realm fatalErrors if I try to use readRealm in multiple serial dispatch blocks? If so, what is the point of the initializer with the queue parameter?