Skip to content

Commit a518edc

Browse files
committed
Note memory semantics in Mutex doc
1 parent ed17bc1 commit a518edc

File tree

1 file changed

+5
-0
lines changed
  • common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/sync

1 file changed

+5
-0
lines changed

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/sync/Mutex.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ import kotlinx.coroutines.experimental.internalAnnotations.*
3030
* Mutex has two states: _locked_ and _unlocked_.
3131
* It is **non-reentrant**, that is invoking [lock] even from the same thread/coroutine that currently holds
3232
* the lock still suspends the invoker.
33+
*
34+
* JVM API note:
35+
* Memory semantic of the [Mutex] is similar to `synchronized` block on JVM:
36+
* An unlock on a [Mutex] happens-before every subsequent successful lock on that [Mutex].
37+
* Unsuccessful call to [tryLock] do not have any memory effects.
3338
*/
3439
public interface Mutex {
3540
/**

0 commit comments

Comments
 (0)