Skip to content

Commit

Permalink
MPP No Trace (#2869)
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev authored Dec 12, 2022
1 parent 1d8ba60 commit 99e50bd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
7 changes: 6 additions & 1 deletion arrow-libs/core/arrow-core/api/arrow-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,11 @@ public final class arrow/core/continuations/AtomicRefKt {
public static final fun updateAndGet (Ljava/util/concurrent/atomic/AtomicReference;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
}

public class arrow/core/continuations/CancellationExceptionNoTrace : java/util/concurrent/CancellationException {
public fun <init> ()V
public fun fillInStackTrace ()Ljava/lang/Throwable;
}

public final class arrow/core/continuations/Eager : arrow/core/continuations/ShiftCancellationException {
public fun <init> (Larrow/core/continuations/Token;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)V
public final fun getRecover ()Lkotlin/jvm/functions/Function1;
Expand Down Expand Up @@ -3015,7 +3020,7 @@ public final class arrow/core/continuations/ResultKt {
public static final fun toResult (Larrow/core/continuations/Effect;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public abstract class arrow/core/continuations/ShiftCancellationException : java/util/concurrent/CancellationException {
public abstract class arrow/core/continuations/ShiftCancellationException : arrow/core/continuations/CancellationExceptionNoTrace {
}

public final class arrow/core/continuations/Suspend : arrow/core/continuations/ShiftCancellationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ public interface Effect<out R, out A> {
* code, you can use this type to differentiate between a foreign [CancellationException] and the
* one from [Effect].
*/
public sealed class ShiftCancellationException : CancellationException("Shifted Continuation")
public sealed class ShiftCancellationException : CancellationExceptionNoTrace()

public expect open class CancellationExceptionNoTrace() : CancellationException

/**
* Holds `R` and `suspend (R) -> B`, the exception that wins the race, will get to execute
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package arrow.core.continuations

import kotlin.coroutines.cancellation.CancellationException

public actual open class CancellationExceptionNoTrace : CancellationException("Shifted Continuation")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package arrow.core.continuations

import kotlin.coroutines.cancellation.CancellationException

/*
* Inspired by KotlinX Coroutines:
* https://github.com/Kotlin/kotlinx.coroutines/blob/3788889ddfd2bcfedbff1bbca10ee56039e024a2/kotlinx-coroutines-core/jvm/src/Exceptions.kt#L29
*/
public actual open class CancellationExceptionNoTrace : CancellationException("Shifted Continuation") {
override fun fillInStackTrace(): Throwable {
// Prevent Android <= 6.0 bug.
stackTrace = emptyArray()
// We don't need stacktrace on shift, it hurts performance.
return this
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package arrow.core.continuations

import kotlin.coroutines.cancellation.CancellationException

public actual open class CancellationExceptionNoTrace : CancellationException("Shifted Continuation")

0 comments on commit 99e50bd

Please sign in to comment.