Skip to content

Commit b1c1310

Browse files
committed
docs: API documentation for ContextValue
1 parent 2163309 commit b1c1310

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kotlin-utils/src/commonMain/kotlin/org/modelix/kotlin/utils/ContextValue.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@
1313
*/
1414
package org.modelix.kotlin.utils
1515

16+
/**
17+
* A common abstraction over ThreadLocal and CoroutineContext that integrates both worlds.
18+
* Allows to set a value that can be read from everywhere on the current thread or coroutine.
19+
* A suspendable function can call non suspendable functions and the value is synchronized between the CoroutineContext
20+
* and the internal ThreadLocal.
21+
*/
1622
expect class ContextValue<E> {
1723

1824
constructor()
1925
constructor(defaultValue: E)
2026

27+
/**
28+
* @throws NoSuchElementException if no value is set.
29+
*/
2130
fun getValue(): E
2231
fun getValueOrNull(): E?
2332
fun getAllValues(): List<E>

0 commit comments

Comments
 (0)