22 " HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE" ,
33 " MISSING_KDOC_TOP_LEVEL" ,
44 " MISSING_KDOC_ON_FUNCTION" ,
5- " FILE_NAME_MATCH_CLASS" ,
6- " MatchingDeclarationName" ,
5+ " FILE_NAME_MATCH_CLASS"
76)
87
98package com.saveourtool.save.core.utils
@@ -15,11 +14,44 @@ import platform.posix.fprintf
1514import platform.posix.stderr
1615import platform.posix.stdout
1716
18- import kotlinx.cinterop.ExperimentalForeignApi
17+ /* *
18+ * Atomic values
19+ */
20+ actual class AtomicInt actual constructor(value : Int ) {
21+ private val holder = kotlin.native.concurrent.AtomicInt (value)
22+
23+ /* *
24+ * @return value
25+ */
26+ actual fun get (): Int = holder.value
27+
28+ /* *
29+ * @param delta increments the value_ by delta
30+ * @return the new value
31+ */
32+ actual fun addAndGet (delta : Int ): Int = holder.addAndGet(delta)
33+ }
34+
35+ @Suppress(" FUNCTION_BOOLEAN_PREFIX" )
36+ actual class AtomicBoolean actual constructor(value : Boolean ) {
37+ private val holder = kotlin.native.concurrent.AtomicReference (value)
38+
39+ /* *
40+ * @return value
41+ */
42+ actual fun get (): Boolean = holder.value
43+
44+ /* *
45+ * @param expect expected value
46+ * @param update updated value
47+ * @return the result of the comparison
48+ */
49+ actual fun compareAndSet (expect : Boolean , update : Boolean ): Boolean = holder.compareAndSet(expect, update)
50+ }
1951
2052@Suppress(" USE_DATA_CLASS" )
2153actual class GenericAtomicReference <T > actual constructor(valueToStore : T ) {
22- private val holder: kotlin.concurrent.AtomicReference <T > = kotlin.concurrent.AtomicReference (valueToStore)
54+ private val holder: kotlin.native. concurrent.AtomicReference <T > = kotlin.native .concurrent.AtomicReference (valueToStore)
2355 actual fun get (): T = holder.value
2456 actual fun set (newValue : T ) {
2557 holder.value = newValue
@@ -72,14 +104,11 @@ actual fun writeToConsole(msg: String, outputType: OutputStreamType) {
72104 * @param msg a message string
73105 * @param output output stream (stdout or stderr)
74106 */
75- private fun processStandardStreams (msg : String , output : OutputStreamType ) {
76- @OptIn(ExperimentalForeignApi ::class )
107+ fun processStandardStreams (msg : String , output : OutputStreamType ) {
77108 val stream = when (output) {
78109 OutputStreamType .STDERR -> stderr
79110 else -> stdout
80111 }
81- @OptIn(ExperimentalForeignApi ::class )
82112 fprintf(stream, msg.escapePercent() + " \n " )
83- @OptIn(ExperimentalForeignApi ::class )
84113 fflush(stream)
85114}
0 commit comments