Skip to content

Commit

Permalink
Update GuiProperty.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkmar committed Mar 29, 2021
1 parent 3514025 commit f7db1b5
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.axay.fabrik.igui.observable

import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlin.reflect.KProperty

class GuiProperty<T>(
Expand All @@ -15,4 +17,13 @@ class GuiProperty<T>(
this.value = value
invokeListeners()
}

private val setValueMutex = Mutex()

suspend fun setValueSuspending(value: T) {
setValueMutex.withLock {
this.value = value
}
invokeListeners()
}
}

0 comments on commit f7db1b5

Please sign in to comment.