File tree 1 file changed +12
-3
lines changed
kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/sync
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -106,18 +106,27 @@ public fun Mutex(locked: Boolean = false): Mutex = MutexImpl(locked)
106
106
107
107
/* *
108
108
* Executes the given [action] under this mutex's lock.
109
+ *
110
+ * @param owner Optional owner token for debugging.
111
+ *
109
112
* @return the return value of the action.
110
113
*/
111
114
// :todo: this function needs to be make inline as soon as this bug is fixed: https://youtrack.jetbrains.com/issue/KT-16448
112
- public suspend fun <T > Mutex.withLock (action : suspend () -> T ): T {
113
- lock()
115
+ public suspend fun <T > Mutex.withLock (owner : Any? = null, action : suspend () -> T ): T {
116
+ lock(owner )
114
117
try {
115
118
return action()
116
119
} finally {
117
- unlock()
120
+ unlock(owner )
118
121
}
119
122
}
120
123
124
+ /* *
125
+ * @suppress: **Deprecated**: Use [withLock]
126
+ */
127
+ @Deprecated(" Use `withLock(owner, action)" , level = DeprecationLevel .HIDDEN )
128
+ public suspend fun <T > Mutex.withLock (action : suspend () -> T ): T = withLock(null , action)
129
+
121
130
/* *
122
131
* @suppress: **Deprecated**: Use [withLock]
123
132
*/
You can’t perform that action at this time.
0 commit comments