diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ChildCloseableState.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ChildCloseableState.kt index 0738fd2..944278e 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ChildCloseableState.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/ChildCloseableState.kt @@ -15,12 +15,6 @@ public sealed class ChildCloseableState : CloseableState { this._state = state } - override fun throwClosed(): Nothing = - this._state.throwClosed() - - override fun throwInUse(): Nothing = - this._state.throwInUse() - override fun assertNotClosed(): Unit = this._state.assertNotClosed() diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableState.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableState.kt index 646c443..2017dc6 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableState.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableState.kt @@ -1,9 +1,6 @@ package ru.landgrafhomyak.utility.closeable_state_1 -public interface CloseableState : AutoCloseable { - public fun throwClosed(): Nothing - public fun throwInUse(): Nothing - +public interface CloseableState { public fun assertNotClosed() public val isClosed: Boolean @@ -15,7 +12,7 @@ public interface CloseableState : AutoCloseable { public fun finishUsage() @ManualStateManipulation - public override fun close() + public fun close() public interface AllowsConcurrency : CloseableState { diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableStateCloseableWrapper.kt b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableStateCloseableWrapper.kt index adb67f9..3d6e9d2 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableStateCloseableWrapper.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/utility/closeable_state_1/CloseableStateCloseableWrapper.kt @@ -8,12 +8,6 @@ public class CloseableStateCloseableWrapper( override val isInUse: Boolean by this._self::isInUse override val isClosed: Boolean by this._self::isInUse - override fun throwClosed(): Nothing = - this._self.throwClosed() - - override fun throwInUse(): Nothing = - this._self.throwInUse() - override fun assertNotClosed(): Unit = this._self.assertNotClosed() 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 f2e7a8f..3ecd9ff 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 @@ -15,15 +15,15 @@ public open class ErrorOnConcurrentAccessState : CloseableState.ExternallySynchr public final override val isInUse: Boolean get() = this._state.get() === State.IN_USE - public open override fun throwClosed(): Nothing { + protected open fun throwClosed(): Nothing { throw IllegalStateException("Object is closed") } - public open override fun throwInUse(): Nothing { + protected open fun throwInUse(): Nothing { throw IllegalStateException("Failed close object because it is in use") } - public open fun throwConcurrent(): Nothing { + protected open fun throwConcurrent(): Nothing { throw IllegalStateException("Object is in use by another thread") } 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 26e1a28..83534ed 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 @@ -17,11 +17,11 @@ public open class UsagesCounter : CloseableState.AllowsConcurrency { public fun getCurrentUsagesCount(): Long = this._value.get() - public open override fun throwClosed(): Nothing { + protected open fun throwClosed(): Nothing { throw IllegalStateException("Object is closed") } - public open override fun throwInUse(): Nothing { + protected open fun throwInUse(): Nothing { throw IllegalStateException("Failed close object because it is in use") }