new: integrate a dispatcher provider and dispatch work
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
internal actual val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import fr.ajaury.gwenedeg.core.coroutines.domain.DispatcherProvider
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
internal class DefaultDispatcherProvider : DispatcherProvider {
|
||||
override val main: CoroutineDispatcher = Dispatchers.Main
|
||||
override val default: CoroutineDispatcher = Dispatchers.Default
|
||||
override val io: CoroutineDispatcher = ioDispatcher
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
|
||||
internal expect val ioDispatcher: CoroutineDispatcher
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.di
|
||||
|
||||
import fr.ajaury.gwenedeg.core.coroutines.data.DefaultDispatcherProvider
|
||||
import fr.ajaury.gwenedeg.core.coroutines.domain.DispatcherProvider
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.dsl.module
|
||||
|
||||
val coroutinesModule: Module = module {
|
||||
single<DispatcherProvider> { DefaultDispatcherProvider() }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.domain
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
|
||||
interface DispatcherProvider {
|
||||
val main: CoroutineDispatcher
|
||||
val default: CoroutineDispatcher
|
||||
val io: CoroutineDispatcher
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
// `Dispatchers.IO` is not public API on Native; `Dispatchers.Default` is multi-threaded here, so it
|
||||
// still runs work off the main thread.
|
||||
internal actual val ioDispatcher: CoroutineDispatcher = Dispatchers.Default
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
// JS is single-threaded; there is no dedicated I/O dispatcher, use default.
|
||||
internal actual val ioDispatcher: CoroutineDispatcher = Dispatchers.Default
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
internal actual val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package fr.ajaury.gwenedeg.core.coroutines.data
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
// Wasm is single-threaded; there is no dedicated I/O dispatcher, use default
|
||||
internal actual val ioDispatcher: CoroutineDispatcher = Dispatchers.Default
|
||||
Reference in New Issue
Block a user