[history] Added .tryDecref{} as opposite operation for .tryIncref{}
This commit is contained in:
parent
be4c578491
commit
f37d81cd60
@ -33,6 +33,11 @@ internal class CloseableReferenceCounter(private val _errMessage: String) {
|
|||||||
this._value.update(Long::dec)
|
this._value.update(Long::dec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <R> tryDecref(block: () -> R): R {
|
||||||
|
this.checkNotClosed()
|
||||||
|
return safeAutoClose2(onSuccess = this::decref, action = block)
|
||||||
|
}
|
||||||
|
|
||||||
fun close(errExistRefs: String) {
|
fun close(errExistRefs: String) {
|
||||||
val state = this._value.compareAndExchange(0, -1)
|
val state = this._value.compareAndExchange(0, -1)
|
||||||
when {
|
when {
|
||||||
|
Loading…
Reference in New Issue
Block a user