Skip to content

Instantly share code, notes, and snippets.

Avatar

Giannis Tsepas gs-ts

View GitHub Profile
@gs-ts
gs-ts / ConcurrencyHelpers.kt
Created Jan 5, 2020 — forked from objcode/ConcurrencyHelpers.kt
Helpers to control concurrency for one shot requests using Kotlin coroutines.
View ConcurrencyHelpers.kt
import kotlinx.coroutines.CoroutineStart.LAZY
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.yield
import java.util.concurrent.atomic.AtomicReference
import kotlin.DeprecationLevel.ERROR