Skip to content

Commit 1d4e7e4

Browse files
committed
Small fixes
1 parent 4c5e3af commit 1d4e7e4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

reactive/kotlinx-coroutines-reactor/src/Flux.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import org.reactivestreams.*
1111
import reactor.core.*
1212
import reactor.core.publisher.*
1313
import reactor.util.context.*
14-
import java.lang.IllegalArgumentException
1514
import kotlin.coroutines.*
1615

1716
/**
18-
* Creates a cold reactive [Flux] that runs a given [block] in a coroutine.
17+
* Creates a cold reactive [Flux] that runs the given [block] in a coroutine.
1918
* Every time the returned flux is subscribed, it starts a new coroutine in the specified [context].
20-
* Coroutine emits ([Subscriber.onNext]) values with [send][ProducerScope.send], completes ([Subscriber.onComplete])
21-
* when the coroutine completes, or the channel is explicitly closed and emits an error ([Subscriber.onError])
22-
* if the coroutine throws an exception or closes the channel with a cause.
19+
* The coroutine emits ([Subscriber.onNext]) values with [send][ProducerScope.send], completes ([Subscriber.onComplete])
20+
* when the coroutine completes, or, in case the coroutine throws an exception or the channel is closed,
21+
* emits the error ([Subscriber.onError]) and closes the channel with the cause.
2322
* Unsubscribing cancels the running coroutine.
2423
*
2524
* Invocations of [send][ProducerScope.send] are suspended appropriately when subscribers apply back-pressure and to

reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import reactor.util.context.*
1212
/**
1313
* Wraps Reactor's [Context] into a [CoroutineContext] element for seamless integration between
1414
* Reactor and kotlinx.coroutines.
15-
* [Context.asCoroutineContext] is defined to place Reactor's [Context] elements into a [CoroutineContext],
15+
* [Context.asCoroutineContext] puts Reactor's [Context] elements into a [CoroutineContext],
1616
* which can be used to propagate the information about Reactor's [Context] through coroutines.
1717
*
18-
* This context element is implicitly propagated through subscriber's context by all Reactive integrations,
18+
* This context element is implicitly propagated through subscribers' context by all Reactive integrations,
1919
* such as [mono], [flux], [Publisher.asFlow][asFlow], [Flow.asPublisher][asPublisher] and [Flow.asFlux][asFlux].
20-
* Functions that subscribe to the reactive stream
20+
* Functions that subscribe to a reactive stream
2121
* (e.g. [Publisher.awaitFirst][kotlinx.coroutines.reactive.awaitFirst]), too, propagate [ReactorContext]
2222
* to the subscriber's [Context].
2323
**
@@ -52,6 +52,7 @@ import reactor.util.context.*
5252
@ExperimentalCoroutinesApi
5353
public class ReactorContext(public val context: Context) : AbstractCoroutineContextElement(ReactorContext) {
5454

55+
// `Context.of` is zero-cost if the argument is a `Context`
5556
public constructor(contextView: ContextView): this(Context.of(contextView))
5657

5758
public companion object Key : CoroutineContext.Key<ReactorContext>
@@ -69,8 +70,8 @@ public fun ContextView.asCoroutineContext(): ReactorContext = ReactorContext(thi
6970
* and later used via `coroutineContext[ReactorContext]`.
7071
*/
7172
@ExperimentalCoroutinesApi
72-
@Deprecated("Use the more general version for ContextView instead", level = DeprecationLevel.HIDDEN)
73-
public fun Context.asCoroutineContext(): ReactorContext = readOnly().asCoroutineContext()
73+
@Deprecated("The more general version for ContextView should be used instead", level = DeprecationLevel.HIDDEN)
74+
public fun Context.asCoroutineContext(): ReactorContext = readOnly().asCoroutineContext() // `readOnly()` is zero-cost.
7475

7576
/**
7677
* Updates the Reactor context in this [CoroutineContext], adding (or possibly replacing) some values.

0 commit comments

Comments
 (0)