Use shared thread pool for queries
This commit is contained in:
@@ -7,6 +7,8 @@ import androidx.room.TypeConverters
|
|||||||
import androidx.room.migration.Migration
|
import androidx.room.migration.Migration
|
||||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Database(entities = [ClientRecord::class, TrafficRecord::class], version = 2)
|
@Database(entities = [ClientRecord::class, TrafficRecord::class], version = 2)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
@@ -15,11 +17,12 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
const val DB_NAME = "app.db"
|
const val DB_NAME = "app.db"
|
||||||
|
|
||||||
val instance by lazy {
|
val instance by lazy {
|
||||||
Room.databaseBuilder(app.deviceStorage, AppDatabase::class.java, DB_NAME)
|
Room.databaseBuilder(app.deviceStorage, AppDatabase::class.java, DB_NAME).apply {
|
||||||
.addMigrations(
|
addMigrations(
|
||||||
Migration2
|
Migration2
|
||||||
)
|
)
|
||||||
.build()
|
setQueryExecutor { GlobalScope.launch { it.run() } }
|
||||||
|
}.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user