Skip to content

Instantly share code, notes, and snippets.

@KwabenBerko
Created July 4, 2023 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KwabenBerko/885d030e2fe8e3185644ac37000b307d to your computer and use it in GitHub Desktop.
Save KwabenBerko/885d030e2fe8e3185644ac37000b307d to your computer and use it in GitHub Desktop.
Mutex Enabled Component
class MutexEnabledComponent: Component {
private val mutex = Mutex()
var refreshesCount: Int = 0
private set
override suspend fun refresh() {
if (!mutex.isLocked){
mutex.withLock {
delay(1L) // Delay to simulate a long running operation
refreshesCount++
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment