Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
durban committed Oct 28, 2024
1 parent eea9bb4 commit 88c2b31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
24 changes: 17 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* limitations under the License.
*/

import com.typesafe.tools.mima.core.{
ProblemFilters,
MissingClassProblem,
}

// Scala versions:
val scala2 = "2.13.15"
val scala3 = "3.3.4"
Expand Down Expand Up @@ -216,13 +221,18 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
.jvmSettings(commonSettingsJvm)
.jsSettings(commonSettingsJs)
.dependsOn(mcas % "compile->compile;test->test")
.settings(libraryDependencies ++= Seq(
dependencies.catsCore.value,
dependencies.catsMtl.value,
dependencies.catsEffectKernel.value,
dependencies.catsEffectStd.value,
// "eu.timepit" %%% "refined" % "0.11.1",
))
.settings(
libraryDependencies ++= Seq(
dependencies.catsCore.value,
dependencies.catsMtl.value,
dependencies.catsEffectKernel.value,
dependencies.catsEffectStd.value,
// "eu.timepit" %%% "refined" % "0.11.1",
),
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[MissingClassProblem]("dev.tauri.choam.core.Rxn$Suspend") // private
),
)

lazy val mcas = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Full)
Expand Down
10 changes: 5 additions & 5 deletions core/shared/src/main/scala/dev/tauri/choam/core/Rxn.scala
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ object Rxn extends RxnInstances0 {
}

/** Only the interpreter can use this! */
private final class Suspend(val token: Long) extends Rxn[Any, Nothing] {
private final class SuspendUntil(val token: Long) extends Rxn[Any, Nothing] {
private[core] final override def tag = 27
final override def toString: String = s"Suspend(${token.toHexString})"
final override def toString: String = s"SuspendUntil(${token.toHexString})"
}

private final class TailRecM[X, A, B](val a: A, val f: A => Rxn[X, Either[A, B]]) extends Rxn[X, B] {
Expand Down Expand Up @@ -1074,7 +1074,7 @@ object Rxn extends RxnInstances0 {
this.startRxn
} else {
assert(canSuspend)
new Suspend(token)
new SuspendUntil(token)
}
}

Expand Down Expand Up @@ -1453,7 +1453,7 @@ object Rxn extends RxnInstances0 {
loop(c.rxn)
case 27 => // Suspend
assert(this.canSuspend)
assert(!Backoff2.isPauseToken(curr.asInstanceOf[Suspend].token))
assert(!Backoff2.isPauseToken(curr.asInstanceOf[SuspendUntil].token))
// user code can't access a `Suspend`, so
// we can abuse `R` and return `Suspend`:
curr.asInstanceOf[R]
Expand All @@ -1477,7 +1477,7 @@ object Rxn extends RxnInstances0 {
this.ctx = mcas.currentContext()
try {
loop(startRxn) match {
case s: Suspend =>
case s: SuspendUntil =>
assert(this._entryHolder eq null)
F.flatMap(poll(Backoff2.tokenToF[F](s.token))) { _ => step(poll) }
case r =>
Expand Down

0 comments on commit 88c2b31

Please sign in to comment.