Skip to content

Instantly share code, notes, and snippets.

@jonnyzzz
Created June 9, 2020 16:25
Show Gist options
  • Select an option

  • Save jonnyzzz/5f8eb0df795e28f179e890c8308fbcad to your computer and use it in GitHub Desktop.

Select an option

Save jonnyzzz/5f8eb0df795e28f179e890c8308fbcad to your computer and use it in GitHub Desktop.
Delegated Properties with Atomic References in Kotlin
class X
operator fun <Y> AtomicReference<Y>.getValue(x: Any?, p: KProperty<*>) : Y = this.get()
operator fun <Y> AtomicReference<Y>.setValue(x: Any?, p: KProperty<*>, value: Y) { this.set(value) }
val myStats by AtomicReference<X>(null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment