Realm perf: use Dispatchers.Default for write, as we don't want to create so many threads (and we can only have one write transaction at a time)

This commit is contained in:
ganfra 2019-11-08 17:08:44 +01:00
parent 17f3614288
commit bcb811a7e8
2 changed files with 2 additions and 2 deletions

View file

@ -23,7 +23,7 @@ import kotlinx.coroutines.withContext
import timber.log.Timber
import java.lang.RuntimeException
suspend fun awaitTransaction(config: RealmConfiguration, transaction: suspend (realm: Realm) -> Unit) = withContext(Dispatchers.IO) {
suspend fun awaitTransaction(config: RealmConfiguration, transaction: suspend (realm: Realm) -> Unit) = withContext(Dispatchers.Default) {
Realm.getInstance(config).use { bgRealm ->
bgRealm.beginTransaction()
try {

View file

@ -111,7 +111,7 @@ internal fun RealmQuery<TimelineEventEntity>.prev(since: Int? = null, strict: Bo
internal fun RealmList<TimelineEventEntity>.find(eventId: String): TimelineEventEntity? {
return this.where()
.equalTo(TimelineEventEntityFields.ROOT.EVENT_ID, eventId)
.equalTo(TimelineEventEntityFields.EVENT_ID, eventId)
.findFirst()
}