godot.coroutines.GodotCoroutine.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of godot-coroutine-library-release Show documentation
Show all versions of godot-coroutine-library-release Show documentation
Godot library extension allowing the use of coroutines in a Godot context.
The newest version!
package godot.coroutines
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext
object GodotCoroutine {
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
operator fun invoke(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit) {
scope.launch(context, start, block)
}
}