synchronizedOnSelf

fun <T : Any, R> T.synchronizedOnSelf(action: () -> R): R

Runs action while holding the monitor/lock associated with this receiver object, returning its result. Shorthand for synchronizedOn(this, action), used e.g. by the internal LRUCache and SimpleLRUCache implementations of Cache to guard all their read/write operations:

override val size
get() = synchronizedOnSelf { cache.size }