[history] Added .toString() for debugging

This commit is contained in:
Andrew Golovashevich 2025-03-19 03:47:10 +03:00
parent f37d81cd60
commit 28b3224e42

View File

@ -51,6 +51,14 @@ internal class CloseableReferenceCounter(private val _errMessage: String) {
return safeAutoClose1(finally = this::decref, action = protected) return safeAutoClose1(finally = this::decref, action = protected)
} }
override fun toString(): String {
val refcntCached = this._value.value
if (refcntCached < 0)
return "<ref counter [closed]>"
else
return "<ref counter [${refcntCached}]>"
}
private fun AtomicLong.compareAndExchange(expected: Long, newValue: Long): Long { private fun AtomicLong.compareAndExchange(expected: Long, newValue: Long): Long {
while (true) { while (true) {
val old = this@compareAndExchange.value val old = this@compareAndExchange.value