Skip to content

Commit f138bbc

Browse files
committed
More kdocs
1 parent 62500ba commit f138bbc

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CoroutineDispatcher.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public abstract class CoroutineDispatcher :
5151
*/
5252
public abstract fun dispatch(context: CoroutineContext, block: Runnable)
5353

54-
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> =
54+
/**
55+
* Returns continuation that wraps the original [continuation], thus intercepting all resumptions.
56+
*/
57+
public override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> =
5558
DispatchedContinuation(this, continuation)
5659

5760
/**

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CoroutineExceptionHandler.kt

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ fun handleCoroutineException(context: CoroutineContext, exception: Throwable) {
4848
* See [handleCoroutineException].
4949
*/
5050
public interface CoroutineExceptionHandler : CoroutineContext.Element {
51+
/**
52+
* Key for [CoroutineExceptionHandler] instance in the coroutine context.
53+
*/
5154
companion object Key : CoroutineContext.Key<CoroutineExceptionHandler>
55+
56+
/**
57+
* Handles uncaught [exception] in the given [context]. It is invoked
58+
* only when everything else fails. See [handleCoroutineException].
59+
*/
5260
public fun handleException(context: CoroutineContext, exception: Throwable)
5361
}

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CoroutineName.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@ import kotlin.coroutines.experimental.CoroutineContext
2323
* User-specified name of coroutine. This name is used in debugging mode.
2424
* See [newCoroutineContext] for the description of coroutine debugging facilities.
2525
*/
26-
public data class CoroutineName(val name: String) : AbstractCoroutineContextElement(CoroutineName) {
26+
public data class CoroutineName(
27+
/**
28+
* User-defined coroutine name.
29+
*/
30+
val name: String
31+
) : AbstractCoroutineContextElement(CoroutineName) {
32+
/**
33+
* Key for [CoroutineName] instance in the coroutine context.
34+
*/
2735
public companion object Key : CoroutineContext.Key<CoroutineName>
36+
37+
/**
38+
* Returns a string representation of the object.
39+
*/
2840
override fun toString(): String = "CoroutineName($name)"
2941
}

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/channels/AbstractChannel.kt

+30
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@ public abstract class AbstractChannel<E> : Channel<E> {
3030

3131
// ------ extension points for buffered channels ------
3232

33+
/**
34+
* Returns `true` if this channel has buffer.
35+
*/
3336
protected abstract val hasBuffer: Boolean
37+
38+
/**
39+
* Returns `true` if this channel's buffer is empty.
40+
*/
3441
protected abstract val isBufferEmpty: Boolean
42+
43+
/**
44+
* Returns `true` if this channel's buffer is full.
45+
*/
3546
protected abstract val isBufferFull: Boolean
3647

3748
/**
@@ -49,7 +60,14 @@ public abstract class AbstractChannel<E> : Channel<E> {
4960

5061
// ------ state functions for concrete implementations ------
5162

63+
/**
64+
* Returns non-null closed token if it is first in the queue.
65+
*/
5266
protected val closedForReceive: Any? get() = queue.next() as? Closed<*>
67+
68+
/**
69+
* Returns non-null closed token if it is last in the queue.
70+
*/
5371
protected val closedForSend: Any? get() = queue.prev() as? Closed<*>
5472

5573
// ------ SendChannel ------
@@ -117,6 +135,9 @@ public abstract class AbstractChannel<E> : Channel<E> {
117135
}
118136
}
119137

138+
/**
139+
* Retrieves first receiving waiter from the queue or returns closed token.
140+
*/
120141
protected fun takeFirstReceiveOrPeekClosed(): ReceiveOrClosed<E>? =
121142
queue.removeFirstIfIsInstanceOfOrPeekIf<ReceiveOrClosed<E>> { it is Closed<*> }
122143

@@ -219,6 +240,9 @@ public abstract class AbstractChannel<E> : Channel<E> {
219240

220241
override fun iterator(): ChannelIterator<E> = Iterator(this)
221242

243+
/**
244+
* Retrieves first sending waiter from the queue or returns closed token.
245+
*/
222246
protected fun takeFirstSendOrPeekClosed(): Send? =
223247
queue.removeFirstIfIsInstanceOfOrPeekIf<Send> { it is Closed<*> }
224248

@@ -297,12 +321,18 @@ public abstract class AbstractChannel<E> : Channel<E> {
297321
}
298322
}
299323

324+
/**
325+
* Represents sending waiter in the queue.
326+
*/
300327
protected interface Send {
301328
val pollResult: Any? // E | Closed
302329
fun tryResumeSend(): Any?
303330
fun completeResumeSend(token: Any)
304331
}
305332

333+
/**
334+
* Represents receiver waiter in the queue or closed token.
335+
*/
306336
protected interface ReceiveOrClosed<in E> {
307337
val offerResult: Any // OFFER_SUCCESS | Closed
308338
fun tryResumeReceive(value: E): Any?

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/channels/ArrayChannel.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ import java.util.concurrent.locks.ReentrantLock
2525
* This implementation uses lock to protect the buffer, which is held only during very short buffer-update operations.
2626
* The lists of suspended senders or receivers are lock-free.
2727
*/
28-
public class ArrayChannel<E>(val capacity: Int) : AbstractChannel<E>() {
28+
public class ArrayChannel<E>(
29+
/**
30+
* Buffer capacity.
31+
*/
32+
val capacity: Int
33+
) : AbstractChannel<E>() {
2934
init {
3035
check(capacity >= 1) { "ArrayChannel capacity must be at least 1, but $capacity was specified" }
3136
}

0 commit comments

Comments
 (0)