Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7689f8e6 authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Automerger Merge Worker
Browse files

Merge "tracinglib: apply latest kt format style" into main am: bf1d4c61

parents 7ae3983f bf1d4c61
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ object FlowTracing {
        flowName: String,
        logcat: Boolean = false,
        traceEmissionCount: Boolean = false,
        crossinline valueToString: (T) -> String = { it.toString() }
        crossinline valueToString: (T) -> String = { it.toString() },
    ): Flow<T> {
        val stateLogger = TraceStateLogger(flowName, logcat = logcat)
        val baseFlow = if (traceEmissionCount) traceEmissionCount(flowName) else this
@@ -51,7 +51,7 @@ object FlowTracing {
    fun <T : Number> Flow<T>.traceAsCounter(
        counterName: String,
        traceEmissionCount: Boolean = false,
        valueToInt: (T) -> Int = { it.toInt() }
        valueToInt: (T) -> Int = { it.toInt() },
    ): Flow<T> {
        val baseFlow = if (traceEmissionCount) traceEmissionCount(counterName) else this
        return baseFlow.onEach {
@@ -80,7 +80,7 @@ object FlowTracing {
     */
    fun <T> Flow<T>.traceEmissionCount(
        flowName: () -> String,
        uniqueSuffix: Boolean = false
        uniqueSuffix: Boolean = false,
    ): Flow<T> {
        val trackName by lazy {
            "${flowName()}#emissionCount" + if (uniqueSuffix) "\$${counter.addAndGet(1)}" else ""
@@ -121,7 +121,7 @@ object FlowTracing {
     */
    fun <T> tracedConflatedCallbackFlow(
        name: String,
        @BuilderInference block: suspend ProducerScope<T>.() -> Unit
        @BuilderInference block: suspend ProducerScope<T>.() -> Unit,
    ): Flow<T> {
        return callbackFlow {
                traceAsync(DEFAULT_ASYNC_TRACK_NAME, { "$name#CallbackFlowBlock" }) {
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ object TraceUtils {
    @JvmStatic
    inline fun traceRunnable(
        crossinline tag: () -> String,
        crossinline block: () -> Unit
        crossinline block: () -> Unit,
    ): Runnable {
        return Runnable { traceSection(tag) { block() } }
    }
+9 −9
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ const val DEFAULT_TRACK_NAME = "Coroutines"
@OptIn(ExperimentalContracts::class)
suspend inline fun <R> coroutineScope(
    traceName: String,
    crossinline block: suspend CoroutineScope.() -> R
    crossinline block: suspend CoroutineScope.() -> R,
): R {
    contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
    return traceCoroutine(traceName) {
@@ -59,7 +59,7 @@ inline fun CoroutineScope.launch(
    crossinline spanName: () -> String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> Unit
    crossinline block: suspend CoroutineScope.() -> Unit,
): Job = launch(context) { traceCoroutine(spanName) { block() } }

/**
@@ -71,7 +71,7 @@ inline fun CoroutineScope.launch(
    spanName: String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> Unit
    crossinline block: suspend CoroutineScope.() -> Unit,
): Job = launch(context) { traceCoroutine(spanName) { block() } }

/**
@@ -83,7 +83,7 @@ inline fun <T> CoroutineScope.async(
    crossinline spanName: () -> String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> T
    crossinline block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(context) { traceCoroutine(spanName) { block() } }

/**
@@ -95,7 +95,7 @@ inline fun <T> CoroutineScope.async(
    spanName: String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> T
    crossinline block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(context) { traceCoroutine(spanName) { block() } }

/**
@@ -106,7 +106,7 @@ inline fun <T> CoroutineScope.async(
inline fun <T> runBlocking(
    crossinline spanName: () -> String,
    context: CoroutineContext,
    crossinline block: suspend () -> T
    crossinline block: suspend () -> T,
): T = runBlocking(context) { traceCoroutine(spanName) { block() } }

/**
@@ -117,7 +117,7 @@ inline fun <T> runBlocking(
inline fun <T> runBlocking(
    spanName: String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T
    crossinline block: suspend CoroutineScope.() -> T,
): T = runBlocking(context) { traceCoroutine(spanName) { block() } }

/**
@@ -128,7 +128,7 @@ inline fun <T> runBlocking(
suspend inline fun <T> withContext(
    spanName: String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T
    crossinline block: suspend CoroutineScope.() -> T,
): T = withContext(context) { traceCoroutine(spanName) { block() } }

/**
@@ -139,7 +139,7 @@ suspend inline fun <T> withContext(
suspend inline fun <T> withContext(
    crossinline spanName: () -> String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T
    crossinline block: suspend CoroutineScope.() -> T,
): T = withContext(context) { traceCoroutine(spanName) { block() } }

/**
+1 −3
Original line number Diff line number Diff line
@@ -42,9 +42,7 @@ class TraceCountThreadLocal : ThreadLocal<Int>() {
 * @see traceCoroutine
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
class TraceData(
    val slices: ArrayDeque<TraceSection> = ArrayDeque(),
) : Cloneable {
class TraceData(val slices: ArrayDeque<TraceSection> = ArrayDeque()) : Cloneable {

    /**
     * ThreadLocal counter for how many open trace sections there are. This is needed because it is
+1 −3
Original line number Diff line number Diff line
@@ -54,9 +54,7 @@ suspend inline fun <T> Flow<T>.collect(
}

@OptIn(ExperimentalTypeInference::class)
suspend inline fun <T> Flow<T>.collectTraced(
    @BuilderInference block: FlowCollector<T>,
) {
suspend inline fun <T> Flow<T>.collectTraced(@BuilderInference block: FlowCollector<T>) {
    collect(walkStackForClassName(), block)
}

Loading