Skip to content

Commit 1616676

Browse files
committed
Improve documentation, make MainScope experimental, cleanup leftovers
1 parent 89d43af commit 1616676

File tree

8 files changed

+22
-10
lines changed

8 files changed

+22
-10
lines changed

binary-compatibility-validator/resources/api.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
#
44

5-
module.roots=core integration native reactive ui test
5+
module.roots=core integration native reactive ui test debug
66
module.marker=build.gradle
77
module.ignore=kotlinx-coroutines-rx-example stdlib-stubs
88

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public operator fun CoroutineScope.plus(context: CoroutineContext): CoroutineSco
9494
* `val scope = MainScope() + CoroutineName("MyActivity")`.
9595
*/
9696
@Suppress("FunctionName")
97+
@ExperimentalCoroutinesApi // Experimental since 1.1.0, tentatively until 1.2.0
9798
public fun MainScope(): CoroutineScope = ContextScope(SupervisorJob() + Dispatchers.Main)
9899

99100
/**
@@ -137,7 +138,7 @@ public val CoroutineScope.isActive: Boolean
137138
*
138139
* ```
139140
*/
140-
object GlobalScope : CoroutineScope {
141+
public object GlobalScope : CoroutineScope {
141142
/**
142143
* Returns [EmptyCoroutineContext].
143144
*/

core/kotlinx-coroutines-core/resources/META-INF/proguard/coroutines.pro

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# ServiceLoader support
22
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
33
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
4-
-keepnames class kotlinx.coroutines.test.internal.InjectableDispatcherFactory {}
54

65
# Most of volatile fields are updated with AFU and should not be mangled
76
-keepclassmembernames class kotlinx.** {

core/kotlinx-coroutines-core/src/internal/MainDispatchers.kt

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ internal object MainDispatcherLoader {
2828
* If anything goes wrong while trying to create main dispatcher (class not found,
2929
* initialization failed, etc), then replace the main dispatcher with a special
3030
* stub that throws an error message on any attempt to actually use it.
31+
*
32+
* @suppress internal API
3133
*/
3234
@InternalCoroutinesApi
3335
public fun MainDispatcherFactory.tryCreateDispatcher(factories: List<MainDispatcherFactory>): MainCoroutineDispatcher =

core/kotlinx-coroutines-core/src/internal/ProbesSupport.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ package kotlinx.coroutines.internal
88
import kotlin.coroutines.*
99
import kotlin.coroutines.jvm.internal.probeCoroutineCreated as probe
1010

11-
internal actual inline fun <T> probeCoroutineCreated(completion: Continuation<T>): Continuation<T> = probe(completion)
11+
internal actual inline fun <T> probeCoroutineCreated(completion: Continuation<T>): Continuation<T> = probe(completion)

core/kotlinx-coroutines-debug/README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ Debugging facilities for `kotlinx.coroutines` on JVM.
44

55
### Overview
66

7-
This module provides a debug JVM agent which allows to track and trace existing coroutines.
7+
This module provides a debug JVM agent that allows to track and trace existing coroutines.
88
The main entry point to debug facilities is [DebugProbes] API.
9-
Call to [DebugProbes.install] installs debug agent via ByteBuddy and starts to spy on coroutines when they are created, suspended or resumed.
9+
Call to [DebugProbes.install] installs debug agent via ByteBuddy and starts spying on coroutines when they are created, suspended and resumed.
1010

1111
After that, you can use [DebugProbes.dumpCoroutines] to print all active (suspended or running) coroutines, including their state, creation and
1212
suspension stacktraces.
1313
Additionally, it is possible to process the list of such coroutines via [DebugProbes.dumpCoroutinesState] or dump isolated parts
14-
of coroutines hierarchy referenced by a [Job] instance using [DebugProbes.printScope] or [DebugProbes.printJob].
14+
of coroutines hierarchy referenced by a [Job] or [CoroutineScope] instances using [DebugProbes.printJob] and [DebugProbes.printScope] respectively.
15+
16+
### Using in your project
17+
18+
Add `kotlinx-coroutines-debug` to your project test dependencies:
19+
```
20+
dependencies {
21+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.1.0-alpha'
22+
}
23+
```
1524

1625
### Using as JVM agent
1726

1827
It is possible to use this module as a standalone JVM agent to enable debug probes on the application startup.
19-
You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.0.1.jar`.
28+
You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.1.0-alpha.jar`.
2029
Additionally, on Linux and Mac OS X you can use `kill -5 $pid` command in order to force your application to print all alive coroutines.
2130

2231

@@ -110,6 +119,7 @@ Do not use this module in production environment and do not rely on the format o
110119
<!--- MODULE kotlinx-coroutines-core -->
111120
<!--- INDEX kotlinx.coroutines -->
112121
[Job]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html
122+
[CoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html
113123
<!--- MODULE kotlinx-coroutines-debug -->
114124
<!--- INDEX kotlinx.coroutines.debug -->
115125
[DebugProbes]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-debug/kotlinx.coroutines.debug/-debug-probes/index.html

core/kotlinx-coroutines-test/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Test utilities for `kotlinx.coroutines`. Provides `Dispatchers.setMain` to overr
77
Add `kotlinx-coroutines-test` to your project test dependencies:
88
```
99
dependencies {
10-
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.0.1'
10+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.0-alpha'
1111
}
1212
```
1313

native/kotlinx-coroutines-core-native/src/internal/ProbesSupport.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ package kotlinx.coroutines.internal
77
import kotlin.coroutines.*
88

99
@Suppress("NOTHING_TO_INLINE")
10-
internal actual inline fun <T> probeCoroutineCreated(completion: Continuation<T>): Continuation<T> = completion
10+
internal actual inline fun <T> probeCoroutineCreated(completion: Continuation<T>): Continuation<T> = completion

0 commit comments

Comments
 (0)