Skip to content

Commit

Permalink
Merge pull request #4184 from typelevel/release/3.5.7-major
Browse files Browse the repository at this point in the history
Merge changes from 3.5.7 into series/3.x
  • Loading branch information
djspiewak authored Nov 26, 2024
2 parents 4a3c96f + 0c80182 commit 3ef2c3d
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 26 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

## Getting Started

- Wired: **3.5.6**
- Wired: **3.5.7**
- Tired: **2.5.5** (end of life)

```scala
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.6"
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.7"
```

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.2, and Scala.js 1.13.
Expand All @@ -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.5.6",
"org.typelevel" %% "cats-effect-laws" % "3.5.6" % Test)
"org.typelevel" %% "cats-effect-kernel" % "3.5.7",
"org.typelevel" %% "cats-effect-laws" % "3.5.7" % 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.5.6",
"org.typelevel" %% "cats-effect" % "3.5.6" % Test)
"org.typelevel" %% "cats-effect-std" % "3.5.7",
"org.typelevel" %% "cats-effect" % "3.5.7" % 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.5.6" % Test
libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.5.7" % 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.
Expand Down
2 changes: 1 addition & 1 deletion docs/core/native-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6",
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.7",
Compile / mainClass := Some("com.example.Main"),
nativeImageOptions += "--no-fallback",
nativeImageVersion := "22.1.0" // It should be at least version 21.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/core/scala-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6",
libraryDependencies += "org.typelevel" %%% "cats-effect" % "3.5.7",
Compile / mainClass := Some("com.example.Main")
)

Expand Down
2 changes: 1 addition & 1 deletion docs/core/test-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6" % Test
libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.5.7" % Test
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: FAQ

```scala-cli
//> using scala "2.13.8"
//> using dep "org.typelevel::cats-effect::3.5.6"
//> using lib "org.typelevel::cats-effect::3.5.7"
import cats.effect._
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Getting Started
Add the following to your **build.sbt**:

```scala
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.6"
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.7"
```

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:
Expand Down Expand Up @@ -68,7 +68,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.5.6`
import $ivy.`org.typelevel::cats-effect:3.5.7`

import cats.effect.unsafe.implicits._
import cats.effect.IO
Expand Down
8 changes: 4 additions & 4 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6",
"org.typelevel" %% "cats-effect-std" % "3.5.6",
"org.typelevel" %% "cats-effect" % "3.5.6",
"org.typelevel" %% "cats-effect-kernel" % "3.5.7",
"org.typelevel" %% "cats-effect-std" % "3.5.7",
"org.typelevel" %% "cats-effect" % "3.5.7",
```

- `kernel` - type class definitions, simple concurrency primitives
Expand All @@ -96,7 +96,7 @@ The current non-test modules are:
libraryDependencies ++= Seq(
//...
- "org.typelevel" %% "cats-effect" % "2.4.0",
+ "org.typelevel" %% "cats-effect" % "3.5.6",
+ "org.typelevel" %% "cats-effect" % "3.5.7",
//...
)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/std/mapref.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ as long as their keys belong to different shards.
This is probably one of the most common uses of this datatype.

```scala mdoc:reset:silent
//> using lib "org.typelevel::cats-effect::3.5.6"
//> using lib "org.typelevel::cats-effect::3.5.7"

import cats.effect.IO
import cats.effect.std.MapRef
Expand Down
2 changes: 1 addition & 1 deletion docs/std/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6"
//> using lib "org.typelevel::cats-effect::3.5.7"

import cats.effect.{IO, IOApp, Sync}
import cats.effect.kernel.Ref
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.6"
version := "3.5.7"

scalaVersion := "2.13.13"

libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.6" withSources() withJavadoc()
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.7" withSources() withJavadoc()

scalacOptions ++= Seq(
"-feature",
Expand Down
11 changes: 6 additions & 5 deletions std/jvm/src/main/scala/cats/effect/std/DispatcherPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,23 @@ private[std] trait DispatcherPlatform[F[_]] { this: Dispatcher[F] =>
}

/**
* Submits an effect to be executed and indefinitely blocks until a result is produced. This
* function will throw an exception if the submitted effect terminates with an error.
* Submits an effect to be executed and indefinitely blocks until a result is produced.
* Cancels the effect in case of Java thread interruption. This function will throw an
* exception if the submitted effect terminates with an error.
*/
def unsafeRunSync[A](fa: F[A]): A =
unsafeRunTimed(fa, Duration.Inf)

/**
* Submits an effect to be executed and blocks for at most the specified timeout for a result
* to be produced. This function will throw an exception if the submitted effect terminates
* with an error.
* to be produced. Cancels the effect both in case of timeout or Java thread interruption.
* This function will throw an exception if the submitted effect terminates with an error.
*/
def unsafeRunTimed[A](fa: F[A], timeout: Duration): A = {
val (fut, cancel) = unsafeToFutureCancelable(fa)
try Await.result(fut, timeout)
catch {
case t: TimeoutException =>
case t @ (_: TimeoutException | _: InterruptedException) =>
cancel()
throw t
}
Expand Down
20 changes: 20 additions & 0 deletions tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package std
import cats.effect.kernel.Deferred
import cats.syntax.all._

import scala.concurrent.duration.DurationInt

class DispatcherJVMSpec extends BaseSpec {

"async dispatcher" should {
Expand All @@ -42,5 +44,23 @@ class DispatcherJVMSpec extends BaseSpec {
}
} yield ok
}

"Propagate Java thread interruption in unsafeRunSync" in real {
Dispatcher.parallel[IO](await = true).use { dispatcher =>
for {
canceled <- Deferred[IO, Unit]
io = IO.sleep(1.second).onCancel(canceled.complete(()).void)
f <- IO.interruptible {
try dispatcher.unsafeRunSync(io)
catch { case _: InterruptedException => }
}.start
_ <- IO.sleep(100.millis)
_ <- f.cancel
_ <- canceled
.get
.timeoutTo(300.millis, IO.raiseError(new Exception("io was not canceled")))
} yield ok
}
}
}
}

0 comments on commit 3ef2c3d

Please sign in to comment.