Coroutine scheduler is used by default instead of deprecated CommonPool
* Documentation and guide are updated correspondingly
* "DefaultDispatcher" is used as a public name of the default impl
* Implementation is integrated with virtual time-source
* Shutdown sequence is reimplemented in a safe way for tests,
makes "close" safe to use on custom instances.
* "close" on DefaultDispatcher throws exception just in case
* -Dkotlinx.coroutines.scheduler=off can be used to switch back to
CommonPool
Fixes #198
diff --git a/docs/coroutine-context-and-dispatchers.md b/docs/coroutine-context-and-dispatchers.md
index e955901..25761b0 100644
--- a/docs/coroutine-context-and-dispatchers.md
+++ b/docs/coroutine-context-and-dispatchers.md
@@ -72,7 +72,7 @@
launch(Dispatchers.Unconfined) { // not confined -- will work with main thread
println("Unconfined : I'm working in thread ${Thread.currentThread().name}")
}
- launch(Dispatchers.Default) { // will get dispatched to ForkJoinPool.commonPool (or equivalent)
+ launch(Dispatchers.Default) { // will get dispatched to DefaultDispatcher
println("Default : I'm working in thread ${Thread.currentThread().name}")
}
launch(newSingleThreadContext("MyOwnThread")) { // will get its own new thread
@@ -89,7 +89,7 @@
```text
Unconfined : I'm working in thread main
-Default : I'm working in thread CommonPool-worker-1
+Default : I'm working in thread DefaultDispatcher-worker-1
newSingleThreadContext: I'm working in thread MyOwnThread
main runBlocking : I'm working in thread main
```
@@ -475,7 +475,7 @@
The output of this code with `-Dkotlinx.coroutines.debug` JVM option is:
```text
-I'm working in thread CommonPool-worker-1 @test#2
+I'm working in thread DefaultDispatcher-worker-1 @test#2
```
<!--- TEST FLEXIBLE_THREAD -->
@@ -632,8 +632,8 @@
```text
Pre-main, current thread: Thread[main @coroutine#1,5,main], thread local value: 'main'
-Launch start, current thread: Thread[CommonPool-worker-1 @coroutine#2,5,main], thread local value: 'launch'
-After yield, current thread: Thread[CommonPool-worker-2 @coroutine#2,5,main], thread local value: 'launch'
+Launch start, current thread: Thread[DefaultDispatcher-worker-1 @coroutine#2,5,main], thread local value: 'launch'
+After yield, current thread: Thread[DefaultDispatcher-worker-2 @coroutine#2,5,main], thread local value: 'launch'
Post-main, current thread: Thread[main @coroutine#1,5,main], thread local value: 'main'
```
diff --git a/docs/exception-handling.md b/docs/exception-handling.md
index 8888c56..6ea9d0d 100644
--- a/docs/exception-handling.md
+++ b/docs/exception-handling.md
@@ -85,7 +85,7 @@
```text
Throwing exception from launch
-Exception in thread "ForkJoinPool.commonPool-worker-2 @coroutine#2" java.lang.IndexOutOfBoundsException
+Exception in thread "DefaultDispatcher-worker-2 @coroutine#2" java.lang.IndexOutOfBoundsException
Joined failed job
Throwing exception from async
Caught ArithmeticException