-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share
runBlockingTest
implementation in jvmAndNative
- Loading branch information
Showing
3 changed files
with
29 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...mAndNative/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJvmAndNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package aws.smithy.kotlin.runtime.http.test.util | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.coroutines.withTimeout | ||
import kotlin.coroutines.CoroutineContext | ||
import kotlin.time.Duration | ||
|
||
internal actual fun runBlockingTest( | ||
context: CoroutineContext, | ||
timeout: Duration?, | ||
block: suspend CoroutineScope.() -> Unit, | ||
) { | ||
runBlocking(context) { | ||
if (timeout != null) { | ||
withTimeout(timeout) { | ||
block() | ||
} | ||
} else { | ||
block() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters