1
0
mirror of https://github.com/etesync/android synced 2024-11-22 07:58:09 +00:00

Revert "Add a reentrant lock to our entity data store."

I'm pretty sure this was causing the recent issues with tasks and events
disappearing as described in #97.

Regardless of this, it's not actually needed as SQLite on Android is
already thread-safe. The SQLite locks some users were experiencing were
probably fixed in 26ea8900a2

This reverts commit 9ed172e23c.
This commit is contained in:
Tom Hacohen 2019-11-04 10:41:47 +02:00
parent 423fcf060c
commit 19b4e2a796

View File

@ -1,60 +1,9 @@
package com.etesync.syncadapter.model package com.etesync.syncadapter.model
import io.requery.Persistable import io.requery.Persistable
import io.requery.meta.Attribute
import io.requery.sql.Configuration import io.requery.sql.Configuration
import io.requery.sql.EntityDataStore import io.requery.sql.EntityDataStore
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
class MyEntityDataStore(configuration: Configuration): EntityDataStore<Persistable>(configuration) { class MyEntityDataStore(configuration: Configuration): EntityDataStore<Persistable>(configuration) {
val lock = ReentrantLock()
override fun <K : Any?, E : Persistable?> insert(entity: E, keyClass: Class<K>?): K {
lock.withLock {
return super.insert(entity, keyClass)
}
}
override fun <E : Persistable?> update(entity: E): E {
lock.withLock {
return super.update(entity)
}
}
override fun <E : Persistable?> update(entity: E, vararg attributes: Attribute<*, *>?): E {
lock.withLock {
return super.update(entity, *attributes)
}
}
override fun <E : Persistable?> upsert(entity: E): E {
lock.withLock {
return super.upsert(entity)
}
}
override fun <E : Persistable?> refresh(entity: E): E {
lock.withLock {
return super.refresh(entity)
}
}
override fun <E : Persistable?> refresh(entity: E, vararg attributes: Attribute<*, *>?): E {
lock.withLock {
return super.refresh(entity, *attributes)
}
}
override fun <E : Persistable?> refreshAll(entity: E): E {
lock.withLock {
return super.refreshAll(entity)
}
}
override fun <E : Persistable?> delete(entity: E): Void {
lock.withLock {
return super.delete(entity)
}
}
} }