Skip to content

Commit

Permalink
Revert "Add a reentrant lock to our entity data store."
Browse files Browse the repository at this point in the history
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 26ea890

This reverts commit 9ed172e.
  • Loading branch information
tasn committed Nov 4, 2019
1 parent 423fcf0 commit 19b4e2a
Showing 1 changed file with 0 additions and 51 deletions.
@@ -1,60 +1,9 @@
package com.etesync.syncadapter.model

import io.requery.Persistable
import io.requery.meta.Attribute
import io.requery.sql.Configuration
import io.requery.sql.EntityDataStore
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock

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)
}
}
}

0 comments on commit 19b4e2a

Please sign in to comment.