File tree 2 files changed +9
-0
lines changed
common/kotlinx-coroutines-core-common
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -185,4 +185,8 @@ fun ReusableCoroutineScope(
185
185
): ReusableCoroutineScope =
186
186
ReusableContextScope (if (context[Job ] != null ) context else context + newJob(), newJob)
187
187
188
+ @Suppress(" FunctionName" )
189
+ fun ReusableMainScope (): CoroutineScope =
190
+ ReusableContextScope (Dispatchers .Main ) { SupervisorJob () }
191
+
188
192
public val CoroutineScope .isReusable: Boolean get() = this is ReusableCoroutineScope
Original file line number Diff line number Diff line change @@ -323,6 +323,11 @@ class CoroutineScopeTest : TestBase() {
323
323
assertTrue(reusableScope.isRestarted)
324
324
}
325
325
326
+ @Test
327
+ fun testMainReusableScope () {
328
+ assertSame(ReusableMainScope ().coroutineContext[ContinuationInterceptor ], Dispatchers .Main )
329
+ }
330
+
326
331
private fun scopePlusContext (c1 : CoroutineContext , c2 : CoroutineContext ) =
327
332
(ContextScope (c1) + c2).coroutineContext
328
333
You can’t perform that action at this time.
0 commit comments