File tree 1 file changed +25
-1
lines changed
kotlinx-coroutines-core/jvm/test/scheduling
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 5
5
package kotlinx.coroutines.scheduling
6
6
7
7
import kotlinx.coroutines.*
8
- import org.junit.*
8
+ import org.junit.Test
9
9
import java.lang.Runnable
10
10
import java.util.concurrent.*
11
11
import kotlin.coroutines.*
12
+ import kotlin.test.*
12
13
13
14
class CoroutineSchedulerTest : TestBase () {
14
15
@@ -127,6 +128,29 @@ class CoroutineSchedulerTest : TestBase() {
127
128
latch.await()
128
129
}
129
130
131
+ @Test
132
+ fun testInterruptionCleanup () {
133
+ ExperimentalCoroutineDispatcher (1 , 1 ).use {
134
+ val executor = it.executor
135
+ var latch = CountDownLatch (1 )
136
+ executor.execute {
137
+ Thread .currentThread().interrupt()
138
+ latch.countDown()
139
+ }
140
+ latch.await()
141
+ Thread .sleep(100 ) // I am really sorry
142
+ latch = CountDownLatch (1 )
143
+ executor.execute {
144
+ try {
145
+ assertFalse(Thread .currentThread().isInterrupted)
146
+ } finally {
147
+ latch.countDown()
148
+ }
149
+ }
150
+ latch.await()
151
+ }
152
+ }
153
+
130
154
private fun testUniformDistribution (worker : CoroutineScheduler .Worker , bound : Int ) {
131
155
val result = IntArray (bound)
132
156
val iterations = 10_000_000
You can’t perform that action at this time.
0 commit comments