All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.org.openrndr.draw.DrawThread.kt Maven / Gradle / Ivy

There is a newer version: 0.4.5-alpha6
Show newest version
package org.openrndr.draw

import kotlinx.coroutines.*
import org.openrndr.internal.Driver
import kotlin.coroutines.CoroutineContext

interface DrawThread {
    val drawer: Drawer
    val dispatcher: CoroutineDispatcher
}

/**
 * launches a coroutine on the [DrawThread]
 */
@Suppress("EXPERIMENTAL_API_USAGE")
fun DrawThread.launch(
        context: CoroutineContext = this.dispatcher,
        start: CoroutineStart = CoroutineStart.DEFAULT,
        block: suspend CoroutineScope.() -> Unit
): Job = GlobalScope.launch(context, start, block)

/**
 * creates and starts a DrawThread
 */
fun drawThread(): DrawThread {
    return Driver.instance.createDrawThread()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy