File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
commonMain/kotlin/kotlinx/atomicfu/locks
concurrentMain/kotlin/kotlinx/atomicfu/locks Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,14 @@ expect class SynchronousMutex() {
37
37
* lock acquisition.
38
38
*/
39
39
fun tryLock (): Boolean
40
-
40
+
41
+ /* *
42
+ * Tries to lock this mutex within the given [timeout] period,
43
+ * returning `false` if the duration passed without locking.
44
+ *
45
+ * Note: when [tryLock] succeeds the lock needs to be released by [unlock].
46
+ * When [tryLock] does not succeed the lock does not have to be released.
47
+ */
41
48
fun tryLock (timeout : Duration ): Boolean
42
49
43
50
/* *
Original file line number Diff line number Diff line change @@ -5,14 +5,16 @@ import kotlinx.atomicfu.atomic
5
5
import kotlin.time.Duration
6
6
import kotlin.time.TimeSource
7
7
8
+ /* *
9
+ * Mutex implementation for Kotlin/Native.
10
+ * In concurrentMain sourceSet to be testable with Lincheck.
11
+ * [park] and [unpark] functions can be passed for testability.
12
+ */
8
13
internal class NativeMutex (
9
14
val park : (Duration ) -> Unit = { ParkingSupport .park(it) },
10
15
val unpark : (ParkingHandle ) -> Unit = ParkingSupport : :unpark,
11
16
) {
12
17
/* *
13
- * Mutex implementation for Kotlin/Native.
14
- * In concurrentMain sourceSet to be testable with Lincheck.
15
- *
16
18
* The [state] variable stands for: 0 -> Lock is free
17
19
* 1 -> Lock is locked but no waiters
18
20
* 4 -> Lock is locked with 3 waiters
You can’t perform that action at this time.
0 commit comments