Skip to content

Instantly share code, notes, and snippets.

@objcode
Created May 21, 2019 06:56
Show Gist options
  • Save objcode/9d3b347ffb34a71e1f7b5249849bfc77 to your computer and use it in GitHub Desktop.
Save objcode/9d3b347ffb34a71e1f7b5249849bfc77 to your computer and use it in GitHub Desktop.
Showing the start of joinPreviosOrRun
// see the complete implementation at
// https://gist.github.com/objcode/7ab4e7b1df8acd88696cb0ccecad16f7#file-concurrencyhelpers-kt-L124
suspend fun joinPreviousOrRun(block: suspend () -> T): T {
// if there is an activeTask, return it's result and don't run the block
activeTask?.let {
return it.await()
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment