diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ErrorOnConcurrentAccessState.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ErrorOnConcurrentAccessState.kt index 8b166bb..f2e7a8f 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ErrorOnConcurrentAccessState.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ErrorOnConcurrentAccessState.kt @@ -12,14 +12,14 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr private val _state = newAtomicRef(State.OPEN) - final override val isInUse: Boolean + public final override val isInUse: Boolean get() = this._state.get() === State.IN_USE - open override fun throwClosed(): Nothing { + public open override fun throwClosed(): Nothing { throw IllegalStateException("Object is closed") } - open override fun throwInUse(): Nothing { + public open override fun throwInUse(): Nothing { throw IllegalStateException("Failed close object because it is in use") } @@ -27,16 +27,16 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr throw IllegalStateException("Object is in use by another thread") } - final override fun assertNotClosed() { + public final override fun assertNotClosed() { if (this._state.get() === State.CLOSED) this.throwClosed() } - final override val isClosed: Boolean + public final override val isClosed: Boolean get() = this._state.get() === State.CLOSED @ManualStateManipulation - final override fun startUsage() { + public final override fun startUsage() { when (this._state.compareAndExchange(State.OPEN, State.IN_USE)) { State.OPEN -> {} State.IN_USE -> this.throwConcurrent() @@ -45,7 +45,7 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr } @ManualStateManipulation - override fun finishUsage() { + public final override fun finishUsage() { when (this._state.compareAndExchange(State.IN_USE, State.OPEN)) { State.OPEN -> throw IllegalStateException("Can't finish usage because not it not started") State.IN_USE -> {} @@ -54,7 +54,7 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr } @ManualStateManipulation - override fun close() { + public final override fun close() { when (this._state.compareAndExchange(State.OPEN, State.CLOSED)) { State.OPEN -> {} State.IN_USE -> this.throwConcurrent() @@ -63,7 +63,7 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr } - override fun toString(): String = + public open override fun toString(): String = when (this._state.get()) { State.OPEN -> "" State.IN_USE -> "" diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/UsagesCounter.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/UsagesCounter.kt index cfdaee2..26e1a28 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/UsagesCounter.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/UsagesCounter.kt @@ -54,7 +54,7 @@ public open class UsagesCounter : CloseableState.AllowsConcurrency { } } - override fun toString(): String { + public open override fun toString(): String { val cached = this._value.get() @Suppress("LiftReturnOrAssignment") if (cached < 0)