@@ -127,9 +127,9 @@ private val LOCKED = Symbol("LOCKED")
127127private 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
134134private class Empty (
135135 @JvmField val locked : Any
@@ -140,7 +140,7 @@ private class Empty(
140140internal 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