'Destructor' annotation
This commit is contained in:
parent
129cee26ca
commit
4ff6c0beb3
@ -29,6 +29,7 @@ public sealed class ChildCloseableState<T : CloseableState> : CloseableState {
|
||||
override fun finishUsage(): Unit =
|
||||
this._state.finishUsage()
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
override fun close() {
|
||||
this._state.finishUsage()
|
||||
|
||||
@ -11,6 +11,7 @@ public interface CloseableState {
|
||||
@ManualStateManipulation
|
||||
public fun finishUsage()
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public fun close()
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ public expect class CloseableStateCloseableWrapper : CloseableState.ExternallySy
|
||||
@ManualStateManipulation
|
||||
override fun finishUsage(close: Boolean)
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
override fun close()
|
||||
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
package ru.landgrafhomyak.utility.closeable_state_1
|
||||
|
||||
/**
|
||||
* Utility annotation to simplify searching method that closes/destructs/deallocs object.
|
||||
*/
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Destructor()
|
||||
@ -24,6 +24,7 @@ public expect open class ErrorOnConcurrentAccessState : CloseableState.Externall
|
||||
@ManualStateManipulation
|
||||
public final override fun finishUsage(close: Boolean)
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public final override fun close()
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ public class HandleWrapper<H>(
|
||||
return this.state.withUse { method(this.handle) }
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public fun close() {
|
||||
this.state.close()
|
||||
|
||||
@ -22,6 +22,7 @@ public expect open class UsagesCounter : CloseableState.AllowsConcurrency {
|
||||
@ManualStateManipulation
|
||||
public final override fun finishUsage()
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public final override fun close()
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ public final class jCloseableStateCloseableWrapper
|
||||
this._self.finishUsage(close);
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@Override
|
||||
public void close() {
|
||||
this._self.close();
|
||||
|
||||
@ -65,6 +65,7 @@ public /* open */ class jErrorOnConcurrentAccessState
|
||||
this._finishUsage(close ? State.CLOSED : State.OPEN);
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@Override
|
||||
public final void close() {
|
||||
switch (this._currentState.compareAndExchange(State.OPEN, State.CLOSED)) {
|
||||
|
||||
@ -50,6 +50,7 @@ public /* open */ class jUsagesCounter
|
||||
}
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@Override
|
||||
public final void close() {
|
||||
long currentReferencesCount;
|
||||
|
||||
@ -48,6 +48,7 @@ public actual class CloseableStateCloseableWrapper : CloseableState.ExternallySy
|
||||
this._self.finishUsage(close)
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
actual override fun close() {
|
||||
this._self.close()
|
||||
|
||||
@ -59,6 +59,7 @@ public actual open class ErrorOnConcurrentAccessState : CloseableState.Externall
|
||||
public actual final override fun finishUsage(close: Boolean): Unit =
|
||||
this._finishUsage(if (close) State.CLOSED else State.OPEN)
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public actual final override fun close() {
|
||||
when (this._state.compareAndExchange(State.OPEN, State.CLOSED)) {
|
||||
|
||||
@ -43,6 +43,7 @@ public actual open class UsagesCounter : CloseableState.AllowsConcurrency {
|
||||
this._value.update(Long::dec)
|
||||
}
|
||||
|
||||
@Destructor
|
||||
@ManualStateManipulation
|
||||
public actual final override fun close() {
|
||||
val state = this._value.compareAndExchange(0, _MiscMultiplatform.CLOSED_STATE_VALUE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user