From 30ff14ef56958b04ab7814ef139df7f540935f54 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Wed, 3 May 2023 01:23:23 +0200 Subject: [PATCH 1/5] Add failing test --- .../test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala index 31efb94d28..2ccef9927d 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala @@ -54,6 +54,7 @@ class WorkerThreadNameSpec extends BaseSpec with TestInstances { "WorkerThread" should { "rename itself when entering and exiting blocking region" in real { for { + _ <- IO.cede computeThread <- threadInfo (computeThreadName, _) = computeThread blockerThread <- IO.blocking(threadInfo).flatten @@ -65,6 +66,8 @@ class WorkerThreadNameSpec extends BaseSpec with TestInstances { } yield { // Start with the regular prefix computeThreadName must startWith("io-compute") + // correct WSTP index (threadCount is 1, so the only possible index is 0) + computeThreadName must endWith("-0") // Check that entering a blocking region changes the name blockerThreadName must startWith("io-blocker") // Check that the same thread is renamed again when it is readded to the compute pool @@ -75,6 +78,8 @@ class WorkerThreadNameSpec extends BaseSpec with TestInstances { "blocker thread not found after reset") resetBlockerThread must beSome((_: String).startsWith("io-compute")) .setMessage("blocker thread name was not reset") + resetBlockerThread must beSome((_: String).endsWith("-0")) + .setMessage("blocker thread index was not correct") } } } From dadbc38c3b46f7394aa9a77a55347bb3f66fe6a4 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Wed, 3 May 2023 01:27:44 +0200 Subject: [PATCH 2/5] Fix initial nameIndex --- core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala b/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala index 8c23c00c8f..d5918d9060 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala @@ -98,7 +98,7 @@ private final class WorkerThread( private val indexTransfer: LinkedTransferQueue[Integer] = new LinkedTransferQueue() private[this] val runtimeBlockingExpiration: Duration = pool.runtimeBlockingExpiration - val nameIndex: Int = pool.blockedWorkerThreadNamingIndex.incrementAndGet() + val nameIndex: Int = pool.blockedWorkerThreadNamingIndex.getAndIncrement() // Constructor code. { From f813fc3f5dffbade27adb34d5a01c5a3e7c5ac87 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Wed, 3 May 2023 02:44:57 +0200 Subject: [PATCH 3/5] Add failing test for new worker naming --- .../scala/cats/effect/unsafe/WorkerThreadNameSpec.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala index 2ccef9927d..f3c936e011 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala @@ -60,16 +60,23 @@ class WorkerThreadNameSpec extends BaseSpec with TestInstances { blockerThread <- IO.blocking(threadInfo).flatten (blockerThreadName, blockerThreadId) = blockerThread _ <- IO.cede + // The new worker (which replaced the thread which became a blocker) should also have a correct name + newComputeThread <- threadInfo + (newComputeThreadName, _) = newComputeThread // Force the previously blocking thread to become a compute thread by converting // the pool of compute threads (size=1) to blocker threads resetComputeThreads <- List.fill(2)(threadInfo <* IO.blocking(())).parSequence } yield { // Start with the regular prefix computeThreadName must startWith("io-compute") - // correct WSTP index (threadCount is 1, so the only possible index is 0) + // Correct WSTP index (threadCount is 1, so the only possible index is 0) computeThreadName must endWith("-0") // Check that entering a blocking region changes the name blockerThreadName must startWith("io-blocker") + // Check that the replacement compute thread has correct name + newComputeThreadName must startWith("io-compute") + // And index + newComputeThreadName must endWith("-0") // Check that the same thread is renamed again when it is readded to the compute pool val resetBlockerThread = resetComputeThreads.collectFirst { case (name, `blockerThreadId`) => name From 7723cf857c9c35c220f56633f836fcd89fbc9cf6 Mon Sep 17 00:00:00 2001 From: Daniel Urban Date: Wed, 3 May 2023 02:49:14 +0200 Subject: [PATCH 4/5] Fix new worker naming --- core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala b/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala index d5918d9060..3a23414cf6 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala @@ -668,6 +668,9 @@ private final class WorkerThread( val idx = index val clone = new WorkerThread(idx, queue, parked, external, fiberBag, pool) + // Make sure the clone gets our old name: + val clonePrefix = pool.threadPrefix + clone.setName(s"$clonePrefix-$idx") pool.replaceWorker(idx, clone) pool.blockedWorkerThreadCounter.incrementAndGet() clone.start() From 85473973972367f20aa53b04cc30de412d4cfc37 Mon Sep 17 00:00:00 2001 From: Daniel Spiewak Date: Thu, 11 May 2023 16:53:40 -0600 Subject: [PATCH 5/5] Updated versions for 3.4.11 --- README.md | 14 +++++++------- docs/core/native-image.md | 2 +- docs/core/scala-native.md | 2 +- docs/core/test-runtime.md | 2 +- docs/faq.md | 2 +- docs/getting-started.md | 4 ++-- docs/migration-guide.md | 14 +++++++------- docs/std/ref.md | 2 +- docs/tutorial.md | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index cb7424fd1c..70913bd590 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ ## Getting Started -- Wired: **3.4.10** +- Wired: **3.4.11** - Tired: **2.5.5** (end of life) ```scala -libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.10" +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.11" ``` The above represents the core, stable dependency which brings in the entirety of Cats Effect. This is *most likely* what you want. All current Cats Effect releases are published for Scala 2.12, 2.13, 3.0, and Scala.js 1.7. @@ -30,22 +30,22 @@ Depending on your use-case, you may want to consider one of the several other mo ```scala libraryDependencies ++= Seq( - "org.typelevel" %% "cats-effect-kernel" % "3.4.10", - "org.typelevel" %% "cats-effect-laws" % "3.4.10" % Test) + "org.typelevel" %% "cats-effect-kernel" % "3.4.11", + "org.typelevel" %% "cats-effect-laws" % "3.4.11" % Test) ``` If you're a middleware framework (like [Fs2](https://fs2.io/)), you probably want to depend on **std**, which gives you access to `Queue`, `Semaphore`, and much more without introducing a hard-dependency on `IO` outside of your tests: ```scala libraryDependencies ++= Seq( - "org.typelevel" %% "cats-effect-std" % "3.4.10", - "org.typelevel" %% "cats-effect" % "3.4.10" % Test) + "org.typelevel" %% "cats-effect-std" % "3.4.11", + "org.typelevel" %% "cats-effect" % "3.4.11" % Test) ``` You may also find some utility in the **testkit** and **kernel-testkit** projects, which contain `TestContext`, generators for `IO`, and a few other things: ```scala -libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.4.10" % Test +libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.4.11" % Test ``` Cats Effect provides backward binary compatibility within the 2.x and 3.x version lines, and both forward and backward compatibility within any major/minor line. This is analogous to the versioning scheme used by Cats itself, as well as other major projects such as Scala.js. Thus, any project depending upon Cats Effect 2.2.1 can be used with libraries compiled against Cats Effect 2.0.0 or 2.2.3, but *not* with libraries compiled against 2.3.0 or higher. diff --git a/docs/core/native-image.md b/docs/core/native-image.md index 20c4965a39..7550bc0d47 100644 --- a/docs/core/native-image.md +++ b/docs/core/native-image.md @@ -33,7 +33,7 @@ ThisBuild / scalaVersion := "2.13.8" lazy val root = (project in file(".")).enablePlugins(NativeImagePlugin).settings( name := "cats-effect-3-hello-world", - libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.10", + libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.11", Compile / mainClass := Some("com.example.Main"), nativeImageOptions += "--no-fallback", nativeImageVersion := "22.1.0" // It should be at least version 21.0.0 diff --git a/docs/core/scala-native.md b/docs/core/scala-native.md index 669154765c..f8d2004cf8 100644 --- a/docs/core/scala-native.md +++ b/docs/core/scala-native.md @@ -22,7 +22,7 @@ lazy val root = project.in(file(".")) .enablePlugins(ScalaNativePlugin) .settings( name := "cats-effect-3-hello-world", - libraryDependencies += "org.typelevel" %%% "cats-effect" % "3.4.10", + libraryDependencies += "org.typelevel" %%% "cats-effect" % "3.4.11", Compile / mainClass := Some("com.example.Main") ) diff --git a/docs/core/test-runtime.md b/docs/core/test-runtime.md index 1f63791b6d..509befa71c 100644 --- a/docs/core/test-runtime.md +++ b/docs/core/test-runtime.md @@ -28,7 +28,7 @@ For those migrating code from Cats Effect 2, `TestControl` is a considerably mor In order to use `TestControl`, you will need to bring in the **cats-effect-testkit** dependency: ```scala -libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.4.10" % Test +libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.4.11" % Test ``` ## Example diff --git a/docs/faq.md b/docs/faq.md index 15baf3a4c3..2ad4dcbf30 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -9,7 +9,7 @@ title: FAQ ```scala-cli //> using scala "2.13.8" -//> using lib "org.typelevel::cats-effect::3.4.10" +//> using lib "org.typelevel::cats-effect::3.4.11" import cats.effect._ diff --git a/docs/getting-started.md b/docs/getting-started.md index 5e3054d4ae..e150671e6e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -6,7 +6,7 @@ title: Getting Started Add the following to your **build.sbt**: ```scala -libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.10" +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.11" ``` Naturally, if you're using ScalaJS, you should replace the double `%%` with a triple `%%%`. If you're on Scala 2, it is *highly* recommended that you enable the [better-monadic-for](https://github.com/oleg-py/better-monadic-for) plugin, which fixes a number of surprising elements of the `for`-comprehension syntax in the Scala language: @@ -62,7 +62,7 @@ We will learn more about constructs like `start` and `*>` in later pages, but fo Of course, the easiest way to play with Cats Effect is to try it out in a Scala REPL. We recommend using [Ammonite](https://ammonite.io/#Ammonite-REPL) for this kind of thing. To get started, run the following lines (if not using Ammonite, skip the first line and make sure that Cats Effect and its dependencies are correctly configured on the classpath): ```scala -import $ivy.`org.typelevel::cats-effect:3.4.10` +import $ivy.`org.typelevel::cats-effect:3.4.11` import cats.effect.unsafe.implicits._ import cats.effect.IO diff --git a/docs/migration-guide.md b/docs/migration-guide.md index 445857d044..501ac41a6a 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -16,7 +16,7 @@ Here is an overview of the steps you should take to migrate your application to ### Before You Begin: This Isn't A "Quick Start" Guide This guide is meant for existing users of Cats Effect 2 who want to upgrade their applications -to 3.4.10. +to 3.4.11. > If you haven't used Cats Effect before and want to give it a try, > please follow the [getting started guide](./getting-started.md) instead! @@ -81,9 +81,9 @@ Cats Effect 3 splits the code dependency into multiple modules. If you were prev The current non-test modules are: ```scala -"org.typelevel" %% "cats-effect-kernel" % "3.4.10", -"org.typelevel" %% "cats-effect-std" % "3.4.10", -"org.typelevel" %% "cats-effect" % "3.4.10", +"org.typelevel" %% "cats-effect-kernel" % "3.4.11", +"org.typelevel" %% "cats-effect-std" % "3.4.11", +"org.typelevel" %% "cats-effect" % "3.4.11", ``` - `kernel` - type class definitions, simple concurrency primitives @@ -96,7 +96,7 @@ The current non-test modules are: libraryDependencies ++= Seq( //... - "org.typelevel" %% "cats-effect" % "2.4.0", -+ "org.typelevel" %% "cats-effect" % "3.4.10", ++ "org.typelevel" %% "cats-effect" % "3.4.11", //... ) ``` @@ -108,8 +108,8 @@ sbt:demo> update [error] stack trace is suppressed; run last core / update for the full output [error] (core / update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] -[error] * org.typelevel:cats-effect_2.13:3.4.10 (early-semver) is selected over {2.3.1, 2.1.4} -[error] +- com.example:core-core_2.13:0.0.7-26-3183519d (depends on 3.4.10) +[error] * org.typelevel:cats-effect_2.13:3.4.11 (early-semver) is selected over {2.3.1, 2.1.4} +[error] +- com.example:core-core_2.13:0.0.7-26-3183519d (depends on 3.4.11) [error] +- io.monix:monix-catnap_2.13:3.3.0 (depends on 2.1.4) [error] +- com.github.valskalla:odin-core_2.13:0.11.0 (depends on 2.3.1) [error] diff --git a/docs/std/ref.md b/docs/std/ref.md index c147be66f3..259d208558 100644 --- a/docs/std/ref.md +++ b/docs/std/ref.md @@ -33,7 +33,7 @@ This is probably one of the most common uses of this concurrency primitive. In this example, the workers will concurrently run and update the value of the `Ref`. ```scala mdoc:reset:silent -//> using lib "org.typelevel::cats-effect:3.4.10" +//> using lib "org.typelevel::cats-effect:3.4.11" import cats.effect.{IO, IOApp, Sync} import cats.effect.kernel.Ref diff --git a/docs/tutorial.md b/docs/tutorial.md index f5d792e267..5c18b99d4c 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -42,11 +42,11 @@ running the code snippets in this tutorial, it is recommended to use the same ```scala name := "cats-effect-tutorial" -version := "3.4.10" +version := "3.4.11" scalaVersion := "2.13.6" -libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.10" withSources() withJavadoc() +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.11" withSources() withJavadoc() scalacOptions ++= Seq( "-feature",