CommonPool deprecated
This commit is contained in:
parent
c315ce5975
commit
e3b1152c5e
@ -60,7 +60,7 @@ class CoroutinesTest {
|
|||||||
|
|
||||||
//when
|
//when
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val promise = launch(CommonPool) { expensiveComputation(res) }
|
val promise = launch(Dispatchers.Default) { expensiveComputation(res) }
|
||||||
res.add("Hello,")
|
res.add("Hello,")
|
||||||
promise.join()
|
promise.join()
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ class CoroutinesTest {
|
|||||||
|
|
||||||
//when
|
//when
|
||||||
val jobs = List(numberOfCoroutines) {
|
val jobs = List(numberOfCoroutines) {
|
||||||
launch(CommonPool) {
|
launch(Dispatchers.Default) {
|
||||||
delay(1L)
|
delay(1L)
|
||||||
counter.incrementAndGet()
|
counter.incrementAndGet()
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ class CoroutinesTest {
|
|||||||
fun givenCancellableJob_whenRequestForCancel_thenShouldQuit() {
|
fun givenCancellableJob_whenRequestForCancel_thenShouldQuit() {
|
||||||
runBlocking<Unit> {
|
runBlocking<Unit> {
|
||||||
//given
|
//given
|
||||||
val job = launch(CommonPool) {
|
val job = launch(Dispatchers.Default) {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
//println("is working")
|
//println("is working")
|
||||||
}
|
}
|
||||||
@ -134,8 +134,8 @@ class CoroutinesTest {
|
|||||||
val delay = 1000L
|
val delay = 1000L
|
||||||
val time = measureTimeMillis {
|
val time = measureTimeMillis {
|
||||||
//given
|
//given
|
||||||
val one = async(CommonPool) { someExpensiveComputation(delay) }
|
val one = async(Dispatchers.Default) { someExpensiveComputation(delay) }
|
||||||
val two = async(CommonPool) { someExpensiveComputation(delay) }
|
val two = async(Dispatchers.Default) { someExpensiveComputation(delay) }
|
||||||
|
|
||||||
//when
|
//when
|
||||||
runBlocking {
|
runBlocking {
|
||||||
@ -155,8 +155,8 @@ class CoroutinesTest {
|
|||||||
val delay = 1000L
|
val delay = 1000L
|
||||||
val time = measureTimeMillis {
|
val time = measureTimeMillis {
|
||||||
//given
|
//given
|
||||||
val one = async(CommonPool, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
|
val one = async(Dispatchers.Default, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
|
||||||
val two = async(CommonPool, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
|
val two = async(Dispatchers.Default, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
|
||||||
|
|
||||||
//when
|
//when
|
||||||
runBlocking {
|
runBlocking {
|
||||||
|
@ -46,7 +46,6 @@ class CoroutineUnitTest {
|
|||||||
return@async "${Thread.currentThread()} has run."
|
return@async "${Thread.currentThread()} has run."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val result = deferred.await()
|
val result = deferred.await()
|
||||||
println(result)
|
println(result)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user