All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.aws.smithy.kotlin.runtime.telemetry.context.TelemetryContextElementJVM.kt Maven / Gradle / Ivy

There is a newer version: 1.3.23
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package aws.smithy.kotlin.runtime.telemetry.context

import aws.smithy.kotlin.runtime.InternalApi
import kotlinx.coroutines.ThreadContextElement
import kotlin.coroutines.AbstractCoroutineContextElement
import kotlin.coroutines.CoroutineContext

@InternalApi
public actual class TelemetryContextElement public actual constructor(
    public actual val context: Context,
) : AbstractCoroutineContextElement(TelemetryContextElement),
    CoroutineContext.Element,
    ThreadContextElement {

    public actual companion object Key : CoroutineContext.Key

    override fun updateThreadContext(context: CoroutineContext): Scope =
        this.context.makeCurrent()

    override fun restoreThreadContext(context: CoroutineContext, oldState: Scope) {
        oldState.close()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy