Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to MacrotaskExecutor on JS #1522

Merged
merged 4 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ val catsEffect_Version = "2.5.1"
val fs2_Version = "2.4.4"
val jcTools_Version = "3.3.0"
val reactiveStreams_Version = "1.0.3"
val macrotaskExecutor_Version = "1.0.0"
val minitest_Version = "2.9.6"
val implicitBox_Version = "0.3.4"
val kindProjector_Version = "0.12.0"
Expand Down Expand Up @@ -77,6 +78,10 @@ lazy val reactiveStreamsLib =
lazy val reactiveStreamsTCKLib =
"org.reactivestreams" % "reactive-streams-tck" % reactiveStreams_Version

/** [[https://github.com/scala-js/scala-js-macrotask-executor]] */
lazy val macrotaskExecutorLib =
Def.setting { "org.scala-js" %%% "scala-js-macrotask-executor" % macrotaskExecutor_Version }

/** [[https://github.com/typelevel/kind-projector]] */
lazy val kindProjectorCompilerPlugin =
"org.typelevel" % "kind-projector" % kindProjector_Version cross CrossVersion.full
Expand Down Expand Up @@ -559,6 +564,7 @@ lazy val executionJVM = project.in(file("monix-execution/jvm"))
lazy val executionJS = project.in(file("monix-execution/js"))
.configure(executionProfile.js)
.settings(macroDependencies)
.settings(libraryDependencies += macrotaskExecutorLib.value)

// --------------------------------------------
// monix-catnap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package monix.execution.schedulers

import monix.execution.{Scheduler, SchedulerCompanion, UncaughtExceptionReporter, ExecutionModel => ExecModel}
import org.scalajs.macrotaskexecutor.MacrotaskExecutor
import scala.concurrent.ExecutionContext

private[execution] class SchedulerCompanionImpl extends SchedulerCompanion {
Expand All @@ -30,14 +31,14 @@ private[execution] class SchedulerCompanionImpl extends SchedulerCompanion {
* [[monix.execution.ExecutionModel ExecutionModel]],
* a guideline for run-loops and producers of data.
*/
def apply(context: ExecutionContext = StandardContext, executionModel: ExecModel = ExecModel.Default): Scheduler =
def apply(context: ExecutionContext = MacrotaskExecutor, executionModel: ExecModel = ExecModel.Default): Scheduler =
AsyncScheduler(context, executionModel)

def apply(ec: ExecutionContext, reporter: UncaughtExceptionReporter): Scheduler =
AsyncScheduler(ec, ExecModel.Default, reporter)

def apply(reporter: UncaughtExceptionReporter, execModel: ExecModel): Scheduler =
AsyncScheduler(StandardContext, execModel, reporter)
AsyncScheduler(MacrotaskExecutor, execModel, reporter)
/** Builds a [[monix.execution.schedulers.TrampolineScheduler TrampolineScheduler]].
*
* @param underlying is the [[monix.execution.Scheduler Scheduler]]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ package monix.execution.internal
import minitest.TestSuite
import monix.execution.atomic.Atomic
import monix.execution.cancelables.SingleAssignCancelable
import monix.execution.schedulers.{AsyncScheduler, StandardContext}
import monix.execution.schedulers.AsyncScheduler
import monix.execution.{ExecutionModel, Scheduler, TestUtils, UncaughtExceptionReporter}
import org.scalajs.macrotaskexecutor.MacrotaskExecutor

import scala.concurrent.Promise
import scala.concurrent.duration._

object AsyncSchedulerJSSuite extends TestSuite[Scheduler] with TestUtils {
val lastReported = Atomic(null: Throwable)
val reporter = new StandardContext(new UncaughtExceptionReporter {
def reportFailure(ex: Throwable): Unit =
lastReported set ex
})
val reporter = MacrotaskExecutor

def setup(): Scheduler = {
lastReported.set(null)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.9.1")
Expand Down