Skip to content

Commit 06600a2

Browse files
committed
Code style improvements
1 parent d8cdc9f commit 06600a2

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
193193
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
194194
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental",
195195
"-Xuse-experimental=kotlin.experimental.ExperimentalTypeInference",
196+
"-Xuse-experimental=kotlin.ExperimentalMultiplatform",
196197
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
197198
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
198199
"-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",

common/kotlinx-coroutines-core-common/src/channels/AbstractChannel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,11 @@ internal val CLOSE_RESUMED: Any = Symbol("CLOSE_RESUMED")
10311031

10321032
@JvmField
10331033
@SharedImmutable
1034-
internal val SEND_RESUMED = Symbol("SEND_RESUMED")
1034+
internal val SEND_RESUMED: Any = Symbol("SEND_RESUMED")
10351035

10361036
@JvmField
10371037
@SharedImmutable
1038-
internal val HANDLER_INVOKED = Symbol("ON_CLOSE_HANDLER_INVOKED")
1038+
internal val HANDLER_INVOKED: Any = Symbol("ON_CLOSE_HANDLER_INVOKED")
10391039

10401040
internal typealias Handler = (Throwable?) -> Unit
10411041

common/kotlinx-coroutines-core-common/src/internal/Concurrent.common.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ internal expect fun <E> identitySet(expectedSize: Int): MutableSet<E>
2525

2626
@ExperimentalMultiplatform
2727
@OptionalExpectation
28-
internal expect annotation class SharedImmutable()
28+
internal expect annotation class SharedImmutable()

common/kotlinx-coroutines-core-common/src/sync/Mutex.kt

+11-11
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ private val LOCKED = Symbol("LOCKED")
127127
private val UNLOCKED = Symbol("UNLOCKED")
128128

129129
@SharedImmutable
130-
private val EmptyLocked = Empty(LOCKED)
130+
private val EMPTY_LOCKED = Empty(LOCKED)
131131
@SharedImmutable
132-
private val EmptyUnlocked = Empty(UNLOCKED)
132+
private val EMPTY_UNLOCKED = Empty(UNLOCKED)
133133

134134
private class Empty(
135135
@JvmField val locked: Any
@@ -140,7 +140,7 @@ private class Empty(
140140
internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
141141
// State is: Empty | LockedQueue | OpDescriptor
142142
// shared objects while we have no waiters
143-
private val _state = atomic<Any?>(if (locked) EmptyLocked else EmptyUnlocked)
143+
private val _state = atomic<Any?>(if (locked) EMPTY_LOCKED else EMPTY_UNLOCKED)
144144

145145
public override val isLocked: Boolean get() {
146146
_state.loop { state ->
@@ -164,7 +164,7 @@ internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
164164
when (state) {
165165
is Empty -> {
166166
if (state.locked !== UNLOCKED) return false
167-
val update = if (owner == null) EmptyLocked else Empty(
167+
val update = if (owner == null) EMPTY_LOCKED else Empty(
168168
owner
169169
)
170170
if (_state.compareAndSet(state, update)) return true
@@ -195,7 +195,7 @@ internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
195195
_state.compareAndSet(state, LockedQueue(state.locked))
196196
} else {
197197
// try lock
198-
val update = if (owner == null) EmptyLocked else Empty(owner)
198+
val update = if (owner == null) EMPTY_LOCKED else Empty(owner)
199199
if (_state.compareAndSet(state, update)) { // locked
200200
cont.resume(Unit)
201201
return@sc
@@ -272,21 +272,21 @@ internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
272272
// This is Harris's RDCSS (Restricted Double-Compare Single Swap) operation
273273
private inner class PrepareOp(private val op: AtomicOp<*>) : OpDescriptor() {
274274
override fun perform(affected: Any?): Any? {
275-
val update: Any = if (op.isDecided) EmptyUnlocked else op // restore if was already decided
275+
val update: Any = if (op.isDecided) EMPTY_UNLOCKED else op // restore if was already decided
276276
(affected as MutexImpl)._state.compareAndSet(this, update)
277277
return null // ok
278278
}
279279
}
280280

281281
override fun prepare(op: AtomicOp<*>): Any? {
282282
val prepare = PrepareOp(op)
283-
if (!mutex._state.compareAndSet(EmptyUnlocked, prepare)) return LOCK_FAIL
283+
if (!mutex._state.compareAndSet(EMPTY_UNLOCKED, prepare)) return LOCK_FAIL
284284
return prepare.perform(mutex)
285285
}
286286

287287
override fun complete(op: AtomicOp<*>, failure: Any?) {
288-
val update = if (failure != null) EmptyUnlocked else {
289-
if (owner == null) EmptyLocked else Empty(owner)
288+
val update = if (failure != null) EMPTY_UNLOCKED else {
289+
if (owner == null) EMPTY_LOCKED else Empty(owner)
290290
}
291291
mutex._state.compareAndSet(op, update)
292292
}
@@ -322,7 +322,7 @@ internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
322322
check(state.locked !== UNLOCKED) { "Mutex is not locked" }
323323
else
324324
check(state.locked === owner) { "Mutex is locked by ${state.locked} but expected $owner" }
325-
if (_state.compareAndSet(state, EmptyUnlocked)) return
325+
if (_state.compareAndSet(state, EMPTY_UNLOCKED)) return
326326
}
327327
is OpDescriptor -> state.perform(this)
328328
is LockedQueue -> {
@@ -406,7 +406,7 @@ internal class MutexImpl(locked: Boolean) : Mutex, SelectClause2<Any?, Mutex> {
406406
will fail anyway.
407407
*/
408408
val success = queue.isEmpty
409-
val update: Any = if (success) EmptyUnlocked else queue
409+
val update: Any = if (success) EMPTY_UNLOCKED else queue
410410
(affected as MutexImpl)._state.compareAndSet(this@UnlockOp, update)
411411
/*
412412
`perform` invocation from the original `unlock` invocation may be coming too late, when

0 commit comments

Comments
 (0)