Created
November 11, 2023 22:11
-
-
Save af2905/547fdfa8b01fa26fce7c8fcaa1e89b80 to your computer and use it in GitHub Desktop.
coroutine_scope_launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kotlinx.coroutines | |
// --------------- launch --------------- | |
public fun CoroutineScope.launch( | |
context: CoroutineContext = EmptyCoroutineContext, | |
start: CoroutineStart = CoroutineStart.DEFAULT, | |
block: suspend CoroutineScope.() -> Unit | |
): Job { | |
val newContext = newCoroutineContext(context) | |
val coroutine = if (start.isLazy) | |
LazyStandaloneCoroutine(newContext, block) else | |
StandaloneCoroutine(newContext, active = true) | |
coroutine.start(start, coroutine, block) | |
return coroutine | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment