Skip to content

Commit 10fd73e

Browse files
authored
Document the fact that dispatch should eventually invoke the given runnable (#1854)
1 parent 737ad1e commit 10fd73e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kotlinx-coroutines-core/common/src/CoroutineDispatcher.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ public abstract class CoroutineDispatcher :
6262

6363
/**
6464
* Dispatches execution of a runnable [block] onto another thread in the given [context].
65+
* This method should guarantee that the given [block] will be eventually invoked,
66+
* otherwise the system may reach a deadlock state and never leave it.
67+
* Cancellation mechanism is transparent for [CoroutineDispatcher] and is managed by [block] internals.
6568
*
6669
* This method should generally be exception-safe. An exception thrown from this method
6770
* may leave the coroutines that use this dispatcher in the inconsistent and hard to debug state.
6871
*
69-
* **Note**: This method must not immediately call [block]. Doing so would result in [StackOverflowError]
72+
* This method must not immediately call [block]. Doing so would result in [StackOverflowError]
7073
* when [yield] is repeatedly called from a loop. However, an implementation that returns `false` from
7174
* [isDispatchNeeded] can delegate this function to `dispatch` method of [Dispatchers.Unconfined], which is
7275
* integrated with [yield] to avoid this problem.
@@ -78,7 +81,7 @@ public abstract class CoroutineDispatcher :
7881
* with a hint for the dispatcher that the current dispatch is triggered by a [yield] call, so that the execution of this
7982
* continuation may be delayed in favor of already dispatched coroutines.
8083
*
81-
* **Implementation note:** Though the `yield` marker may be passed as a part of [context], this
84+
* Though the `yield` marker may be passed as a part of [context], this
8285
* is a separate method for performance reasons.
8386
*
8487
* @suppress **This an internal API and should not be used from general code.**

0 commit comments

Comments
 (0)