diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16113d852e..2678ec28ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -532,7 +532,7 @@ jobs: - name: Post release to Discord env: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - run: scripts/post-release-discord ${{ github.ref }} + run: scripts/post-release-discord.sh ${{ github.ref }} dependency-submission: name: Submit Dependencies diff --git a/README.md b/README.md index bfe0f4b4f5..bbabf866ec 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ ## Getting Started -- Wired: **3.5.3** +- Wired: **3.5.4** - Tired: **2.5.5** (end of life) ```scala -libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.3" +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.4" ``` 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.5.3", - "org.typelevel" %% "cats-effect-laws" % "3.5.3" % Test) + "org.typelevel" %% "cats-effect-kernel" % "3.5.4", + "org.typelevel" %% "cats-effect-laws" % "3.5.4" % 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.3", - "org.typelevel" %% "cats-effect" % "3.5.3" % Test) + "org.typelevel" %% "cats-effect-std" % "3.5.4", + "org.typelevel" %% "cats-effect" % "3.5.4" % 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.3" % Test +libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.5.4" % 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/RELEASING.md b/RELEASING.md index dc61fab879..b7682e952f 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -14,13 +14,13 @@ 1. Publish the release. 1. Wait for all the CI madness to happen, for the release to announced to Discord, and for the artifacts to sync to Maven Central. 1. Make sure you're locally updated and on the right major/minor branch (this is the same branch as step 3). -1. Open a PR to merge the minor branch into the major branch. This is only necessary for patch releases. +1. Run the following script to open two PRs to (1) update the version in the README/docs of the minor branch and then (2) merge the minor branch into the major branch. This script currently works only for patch releases and not for minor releases, milestones, or release candidates, which need special handling. `scripts/make-release-prs.sh ` e.g. `scripts/make-release-prs.sh v3.5.1 v3.5.2` -1. Open a PR to update the version in the README and documentation site. This is only necessary for stable releases (i.e., not Milestones or Release Candidates) +1. Open a PR to the docs branch to update the landing page. This is only necessary for stable releases (i.e., not milestones or release candidates) `scripts/make-site-pr.sh ` diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/AsyncBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/AsyncBenchmark.scala index 6d8c2c716f..721d6b39b9 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/AsyncBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/AsyncBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/AtomicCellBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/AtomicCellBenchmark.scala index 610208e91c..4be8a362c1 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/AtomicCellBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/AtomicCellBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/AttemptBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/AttemptBenchmark.scala index 99333a1672..48930f9d05 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/AttemptBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/AttemptBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/BlockingBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/BlockingBenchmark.scala index a29d9d98ab..a3587a99b6 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/BlockingBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/BlockingBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/BothBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/BothBenchmark.scala index 153815b9c4..3244f9c030 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/BothBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/BothBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/DeepBindBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/DeepBindBenchmark.scala index 0491e4819e..3198c905c5 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/DeepBindBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/DeepBindBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/DeferredBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/DeferredBenchmark.scala index b547f9edf9..01bfdc1842 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/DeferredBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/DeferredBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/DispatcherBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/DispatcherBenchmark.scala index 9ca8f58eb4..6f81a257cf 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/DispatcherBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/DispatcherBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/HandleErrorBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/HandleErrorBenchmark.scala index 1452aaa5ad..88a2d145d8 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/HandleErrorBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/HandleErrorBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/MapCallsBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/MapCallsBenchmark.scala index 3c31c42870..153cf3fe32 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/MapCallsBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/MapCallsBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/MapStreamBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/MapStreamBenchmark.scala index 85fda56bc5..0389158f18 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/MapStreamBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/MapStreamBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/MutexBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/MutexBenchmark.scala index 2b77a5d7fe..178c4e9c5e 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/MutexBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/MutexBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/ParallelBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/ParallelBenchmark.scala index 65a5b9784c..60745710f8 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/ParallelBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/ParallelBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/QueueBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/QueueBenchmark.scala index 4e8b2190d3..6a34c7fcca 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/QueueBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/QueueBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/RaceBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/RaceBenchmark.scala index bc01022670..df383b493b 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/RaceBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/RaceBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/RandomBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/RandomBenchmark.scala index dd93431081..40f32b7e21 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/RandomBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/RandomBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemBenchmark.scala index 80eb1f3e7c..938be317f7 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemWithBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemWithBenchmark.scala index fa7ba4b25c..2549385a76 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemWithBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/RedeemWithBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/RefBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/RefBenchmark.scala index 9971e2dd50..5c54b9dc60 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/RefBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/RefBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/ScalQueueBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/ScalQueueBenchmark.scala index a85d6549a7..19ae23b0da 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/ScalQueueBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/ScalQueueBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/ShallowBindBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/ShallowBindBenchmark.scala index b573740caf..4c24a466bf 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/ShallowBindBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/ShallowBindBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/SleepBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/SleepBenchmark.scala index 38f21e6803..7e92003b76 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/SleepBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/SleepBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/SleepDrift.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/SleepDrift.scala index 0a4a037b35..1e5af228ce 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/SleepDrift.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/SleepDrift.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/ThreadLocalBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/ThreadLocalBenchmark.scala index 54409fbcb8..44cae73d9d 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/ThreadLocalBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/ThreadLocalBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/benchmarks/src/main/scala/cats/effect/benchmarks/WorkStealingBenchmark.scala b/benchmarks/src/main/scala/cats/effect/benchmarks/WorkStealingBenchmark.scala index f1f2f3fa4c..0024abe8b5 100644 --- a/benchmarks/src/main/scala/cats/effect/benchmarks/WorkStealingBenchmark.scala +++ b/benchmarks/src/main/scala/cats/effect/benchmarks/WorkStealingBenchmark.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/build.sbt b/build.sbt index ae6ee25665..52893353a9 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,7 +223,7 @@ ThisBuild / githubWorkflowBuild := Seq("JVM", "JS", "Native").map { platform => ThisBuild / githubWorkflowPublish += WorkflowStep.Run( - List("scripts/post-release-discord ${{ github.ref }}"), + List("scripts/post-release-discord.sh ${{ github.ref }}"), name = Some("Post release to Discord"), env = Map("DISCORD_WEBHOOK_URL" -> "${{ secrets.DISCORD_WEBHOOK_URL }}") ) @@ -669,6 +669,8 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) ProblemFilters.exclude[IncompatibleResultTypeProblem]("cats.effect.CallbackStack.push"), ProblemFilters.exclude[DirectMissingMethodProblem]( "cats.effect.CallbackStack.currentHandle"), + // #3973, remove clear from internal private CallbackStack + ProblemFilters.exclude[DirectMissingMethodProblem]("cats.effect.CallbackStack.clear"), // introduced by #3332, polling system ProblemFilters.exclude[DirectMissingMethodProblem]( "cats.effect.unsafe.IORuntimeBuilder.this"), @@ -1030,7 +1032,18 @@ lazy val std = crossProject(JSPlatform, JVMPlatform, NativePlatform) "cats.effect.std.Queue$UnsafeUnbounded$Cell"), // introduced by #3480 // adds method to sealed Hotswap - ProblemFilters.exclude[ReversedMissingMethodProblem]("cats.effect.std.Hotswap.get") + ProblemFilters.exclude[ReversedMissingMethodProblem]("cats.effect.std.Hotswap.get"), + // #3972, private trait + ProblemFilters.exclude[IncompatibleTemplateDefProblem]( + "cats.effect.std.Supervisor$State"), + // introduced by #3923 + // Rewrote Dispatcher + ProblemFilters.exclude[MissingClassProblem]("cats.effect.std.Dispatcher$Mode"), + ProblemFilters.exclude[MissingClassProblem]("cats.effect.std.Dispatcher$Mode$"), + ProblemFilters.exclude[MissingClassProblem]( + "cats.effect.std.Dispatcher$Mode$Parallel$"), + ProblemFilters.exclude[MissingClassProblem]( + "cats.effect.std.Dispatcher$Mode$Sequential$") ) ) .jsSettings( diff --git a/core/js-native/src/main/scala/cats/effect/IOFiberConstants.scala b/core/js-native/src/main/scala/cats/effect/IOFiberConstants.scala index b389cddae8..c12106b1dd 100644 --- a/core/js-native/src/main/scala/cats/effect/IOFiberConstants.scala +++ b/core/js-native/src/main/scala/cats/effect/IOFiberConstants.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js-native/src/main/scala/cats/effect/IOFiberPlatform.scala b/core/js-native/src/main/scala/cats/effect/IOFiberPlatform.scala index d7ce0a6ef1..bf6bbe48ef 100644 --- a/core/js-native/src/main/scala/cats/effect/IOFiberPlatform.scala +++ b/core/js-native/src/main/scala/cats/effect/IOFiberPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js-native/src/main/scala/cats/effect/SyncIOConstants.scala b/core/js-native/src/main/scala/cats/effect/SyncIOConstants.scala index 7818543b53..82078483e5 100644 --- a/core/js-native/src/main/scala/cats/effect/SyncIOConstants.scala +++ b/core/js-native/src/main/scala/cats/effect/SyncIOConstants.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js-native/src/main/scala/cats/effect/unsafe/FiberExecutor.scala b/core/js-native/src/main/scala/cats/effect/unsafe/FiberExecutor.scala index cfe694de74..3328ec352e 100644 --- a/core/js-native/src/main/scala/cats/effect/unsafe/FiberExecutor.scala +++ b/core/js-native/src/main/scala/cats/effect/unsafe/FiberExecutor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js-native/src/main/scala/cats/effect/unsafe/FiberMonitor.scala b/core/js-native/src/main/scala/cats/effect/unsafe/FiberMonitor.scala index 147ea719b4..70a1fe5257 100644 --- a/core/js-native/src/main/scala/cats/effect/unsafe/FiberMonitor.scala +++ b/core/js-native/src/main/scala/cats/effect/unsafe/FiberMonitor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js-native/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala b/core/js-native/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala index 6e5a1086fb..acbe94c077 100644 --- a/core/js-native/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala +++ b/core/js-native/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/ArrayStack.scala b/core/js/src/main/scala/cats/effect/ArrayStack.scala index 591872d8c4..1acdb97d50 100644 --- a/core/js/src/main/scala/cats/effect/ArrayStack.scala +++ b/core/js/src/main/scala/cats/effect/ArrayStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/ByteStack.scala b/core/js/src/main/scala/cats/effect/ByteStack.scala index c4e387f749..4c1a43495a 100644 --- a/core/js/src/main/scala/cats/effect/ByteStack.scala +++ b/core/js/src/main/scala/cats/effect/ByteStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/CallbackStack.scala b/core/js/src/main/scala/cats/effect/CallbackStack.scala index 87867c3090..a75d2db723 100644 --- a/core/js/src/main/scala/cats/effect/CallbackStack.scala +++ b/core/js/src/main/scala/cats/effect/CallbackStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala b/core/js/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala index 5c12a733bd..f35313ffd7 100644 --- a/core/js/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala +++ b/core/js/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/IOApp.scala b/core/js/src/main/scala/cats/effect/IOApp.scala index 5f5e1b9b39..332de3ac9c 100644 --- a/core/js/src/main/scala/cats/effect/IOApp.scala +++ b/core/js/src/main/scala/cats/effect/IOApp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/IOCompanionPlatform.scala b/core/js/src/main/scala/cats/effect/IOCompanionPlatform.scala index eff89f8c55..bce2b82ed0 100644 --- a/core/js/src/main/scala/cats/effect/IOCompanionPlatform.scala +++ b/core/js/src/main/scala/cats/effect/IOCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/IOPlatform.scala b/core/js/src/main/scala/cats/effect/IOPlatform.scala index 2724367516..e3c114ab37 100644 --- a/core/js/src/main/scala/cats/effect/IOPlatform.scala +++ b/core/js/src/main/scala/cats/effect/IOPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/Platform.scala b/core/js/src/main/scala/cats/effect/Platform.scala index f7792a16ce..4693a3b706 100644 --- a/core/js/src/main/scala/cats/effect/Platform.scala +++ b/core/js/src/main/scala/cats/effect/Platform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala b/core/js/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala index 17c95b3a70..b440693a65 100644 --- a/core/js/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala +++ b/core/js/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/metrics/JsCpuStarvationMetrics.scala b/core/js/src/main/scala/cats/effect/metrics/JsCpuStarvationMetrics.scala index 3353e9ef30..dc227de3ba 100644 --- a/core/js/src/main/scala/cats/effect/metrics/JsCpuStarvationMetrics.scala +++ b/core/js/src/main/scala/cats/effect/metrics/JsCpuStarvationMetrics.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/process.scala b/core/js/src/main/scala/cats/effect/process.scala index dd8738ec3d..efc9994802 100644 --- a/core/js/src/main/scala/cats/effect/process.scala +++ b/core/js/src/main/scala/cats/effect/process.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala b/core/js/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala index 379a493e82..339ee0e169 100644 --- a/core/js/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala +++ b/core/js/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/tracing/TracingConstants.scala b/core/js/src/main/scala/cats/effect/tracing/TracingConstants.scala index 04a6a096db..5045b162d9 100644 --- a/core/js/src/main/scala/cats/effect/tracing/TracingConstants.scala +++ b/core/js/src/main/scala/cats/effect/tracing/TracingConstants.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala b/core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala index f44bb8e176..9b5ed6a139 100644 --- a/core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala +++ b/core/js/src/main/scala/cats/effect/tracing/TracingPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala b/core/js/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala index 6dc3496bb3..e9a8aa7e30 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala b/core/js/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala index 0e60f17760..a9cce1cb31 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala index 7583f65e9c..b4837102a9 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala index f103f9cb96..4b6ea179d2 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala index 217a0ca63d..c695beed81 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/JSArrayQueue.scala b/core/js/src/main/scala/cats/effect/unsafe/JSArrayQueue.scala index ead6c6979e..a801493f72 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/JSArrayQueue.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/JSArrayQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala b/core/js/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala index 20b02231fa..b57ced7924 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/ref/Reference.scala b/core/js/src/main/scala/cats/effect/unsafe/ref/Reference.scala index 151b903ad8..1cbe2a9bb5 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/ref/Reference.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/ref/Reference.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/ref/ReferenceQueue.scala b/core/js/src/main/scala/cats/effect/unsafe/ref/ReferenceQueue.scala index 2cbc00e605..f012479bce 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/ref/ReferenceQueue.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/ref/ReferenceQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/js/src/main/scala/cats/effect/unsafe/ref/WeakReference.scala b/core/js/src/main/scala/cats/effect/unsafe/ref/WeakReference.scala index 8896ee0700..de69a5cc64 100644 --- a/core/js/src/main/scala/cats/effect/unsafe/ref/WeakReference.scala +++ b/core/js/src/main/scala/cats/effect/unsafe/ref/WeakReference.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/ArrayStack.scala b/core/jvm-native/src/main/scala/cats/effect/ArrayStack.scala index 97529d501e..ae5d5f7e25 100644 --- a/core/jvm-native/src/main/scala/cats/effect/ArrayStack.scala +++ b/core/jvm-native/src/main/scala/cats/effect/ArrayStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/ByteStack.scala b/core/jvm-native/src/main/scala/cats/effect/ByteStack.scala index 9bdbdaf1f6..cfbb70cb39 100644 --- a/core/jvm-native/src/main/scala/cats/effect/ByteStack.scala +++ b/core/jvm-native/src/main/scala/cats/effect/ByteStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/CallbackStack.scala b/core/jvm-native/src/main/scala/cats/effect/CallbackStack.scala index 37c10ced94..bad66991eb 100644 --- a/core/jvm-native/src/main/scala/cats/effect/CallbackStack.scala +++ b/core/jvm-native/src/main/scala/cats/effect/CallbackStack.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,26 +61,42 @@ private final class CallbackStack[A](private[this] var callback: A => Unit) */ def apply(a: A): Boolean = { // see also note about data races in Node#packTail - - val cb = callback - var invoked = if (cb != null) { - cb(a) - true - } else { - false - } var currentNode = head.get() - - while (currentNode ne null) { - val cb = currentNode.getCallback() - if (cb != null) { + try { + val cb = callback + var invoked = if (cb != null) { cb(a) - invoked = true + true + } else { + false } - currentNode = currentNode.getNext() - } - invoked + // note that we're tearing down the callback stack structure behind us as we go + while (currentNode ne null) { + val cb = currentNode.getCallback() + if (cb != null) { + cb(a) + currentNode.clear() + invoked = true + } + val nextNode = currentNode.getNext() + currentNode.setNext(null) + currentNode = nextNode + } + head.lazySet(null) + + invoked + } finally { + // if a callback throws, we stop invoking remaining callbacks + // but we continue the process of tearing down the stack to prevent memory leaks + while (currentNode ne null) { + val nextNode = currentNode.getNext() + currentNode.clear() + currentNode.setNext(null) + currentNode = nextNode + } + head.lazySet(null) + } } /** @@ -92,14 +108,6 @@ private final class CallbackStack[A](private[this] var callback: A => Unit) false } - /** - * Nulls all references in this callback stack. - */ - def clear(): Unit = { - callback = null - head.lazySet(null) - } - /** * It is intended that `bound` be tracked externally and incremented on each clear(). Whenever * pack is called, the number of empty cells removed from the stack is produced. It is diff --git a/core/jvm-native/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala b/core/jvm-native/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala index 96ca5a7016..8aa1d96b8c 100644 --- a/core/jvm-native/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala +++ b/core/jvm-native/src/main/scala/cats/effect/CpuStarvationCheckPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala b/core/jvm-native/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala index c06aacad6b..2d5e392bf8 100644 --- a/core/jvm-native/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala +++ b/core/jvm-native/src/main/scala/cats/effect/SyncIOCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala b/core/jvm-native/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala index 5ed6c3e6a6..e5534f6c9e 100644 --- a/core/jvm-native/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala +++ b/core/jvm-native/src/main/scala/cats/effect/syntax/DispatcherSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala b/core/jvm-native/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala index 3a999a3b50..c47581be33 100644 --- a/core/jvm-native/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala +++ b/core/jvm-native/src/main/scala/cats/effect/unsafe/BatchingMacrotaskExecutor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/unsafe/PollingSystem.scala b/core/jvm-native/src/main/scala/cats/effect/unsafe/PollingSystem.scala index c4aa0d2b2d..cc36ef2b8d 100644 --- a/core/jvm-native/src/main/scala/cats/effect/unsafe/PollingSystem.scala +++ b/core/jvm-native/src/main/scala/cats/effect/unsafe/PollingSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm-native/src/main/scala/cats/effect/unsafe/ref/package.scala b/core/jvm-native/src/main/scala/cats/effect/unsafe/ref/package.scala index 8afbda8251..64805e54d1 100644 --- a/core/jvm-native/src/main/scala/cats/effect/unsafe/ref/package.scala +++ b/core/jvm-native/src/main/scala/cats/effect/unsafe/ref/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/IOFiberConstants.java b/core/jvm/src/main/java/cats/effect/IOFiberConstants.java index 0adf899b2f..92a7c861a5 100644 --- a/core/jvm/src/main/java/cats/effect/IOFiberConstants.java +++ b/core/jvm/src/main/java/cats/effect/IOFiberConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/Signal.java b/core/jvm/src/main/java/cats/effect/Signal.java index df7cbd5ae1..f8ca349e52 100644 --- a/core/jvm/src/main/java/cats/effect/Signal.java +++ b/core/jvm/src/main/java/cats/effect/Signal.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/SyncIOConstants.java b/core/jvm/src/main/java/cats/effect/SyncIOConstants.java index c0edee03cd..9a3889729f 100644 --- a/core/jvm/src/main/java/cats/effect/SyncIOConstants.java +++ b/core/jvm/src/main/java/cats/effect/SyncIOConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/tracing/TracingConstants.java b/core/jvm/src/main/java/cats/effect/tracing/TracingConstants.java index 6b9d477af1..7e223d1b79 100644 --- a/core/jvm/src/main/java/cats/effect/tracing/TracingConstants.java +++ b/core/jvm/src/main/java/cats/effect/tracing/TracingConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/unsafe/LocalQueue.java b/core/jvm/src/main/java/cats/effect/unsafe/LocalQueue.java index e59b8bc928..0918edc347 100644 --- a/core/jvm/src/main/java/cats/effect/unsafe/LocalQueue.java +++ b/core/jvm/src/main/java/cats/effect/unsafe/LocalQueue.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/unsafe/LocalQueueConstants.java b/core/jvm/src/main/java/cats/effect/unsafe/LocalQueueConstants.java index d0d29bbac2..d236825729 100644 --- a/core/jvm/src/main/java/cats/effect/unsafe/LocalQueueConstants.java +++ b/core/jvm/src/main/java/cats/effect/unsafe/LocalQueueConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/java/cats/effect/unsafe/WorkStealingThreadPoolConstants.java b/core/jvm/src/main/java/cats/effect/unsafe/WorkStealingThreadPoolConstants.java index ebb1a8430a..04837b7379 100644 --- a/core/jvm/src/main/java/cats/effect/unsafe/WorkStealingThreadPoolConstants.java +++ b/core/jvm/src/main/java/cats/effect/unsafe/WorkStealingThreadPoolConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/IOApp.scala b/core/jvm/src/main/scala/cats/effect/IOApp.scala index f9b8198701..0dc1a06530 100644 --- a/core/jvm/src/main/scala/cats/effect/IOApp.scala +++ b/core/jvm/src/main/scala/cats/effect/IOApp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/IOCompanionPlatform.scala b/core/jvm/src/main/scala/cats/effect/IOCompanionPlatform.scala index 2ef6e86788..01c7a46467 100644 --- a/core/jvm/src/main/scala/cats/effect/IOCompanionPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/IOCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/IOFiberPlatform.scala b/core/jvm/src/main/scala/cats/effect/IOFiberPlatform.scala index 88218ca556..ab5929b39c 100644 --- a/core/jvm/src/main/scala/cats/effect/IOFiberPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/IOFiberPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/IOPlatform.scala b/core/jvm/src/main/scala/cats/effect/IOPlatform.scala index ff2285e7a9..c4a68d5a76 100644 --- a/core/jvm/src/main/scala/cats/effect/IOPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/IOPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/NonDaemonThreadLogger.scala b/core/jvm/src/main/scala/cats/effect/NonDaemonThreadLogger.scala index c16666932b..a4a7f28111 100644 --- a/core/jvm/src/main/scala/cats/effect/NonDaemonThreadLogger.scala +++ b/core/jvm/src/main/scala/cats/effect/NonDaemonThreadLogger.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/Platform.scala b/core/jvm/src/main/scala/cats/effect/Platform.scala index 4f166221dc..38540a15b0 100644 --- a/core/jvm/src/main/scala/cats/effect/Platform.scala +++ b/core/jvm/src/main/scala/cats/effect/Platform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/Selector.scala b/core/jvm/src/main/scala/cats/effect/Selector.scala index 586c448342..da39e74d90 100644 --- a/core/jvm/src/main/scala/cats/effect/Selector.scala +++ b/core/jvm/src/main/scala/cats/effect/Selector.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvation.scala b/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvation.scala index 635bdd3ac7..08164fffad 100644 --- a/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvation.scala +++ b/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvation.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvationMbean.scala b/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvationMbean.scala index 7d2e7176da..ee61c22344 100644 --- a/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvationMbean.scala +++ b/core/jvm/src/main/scala/cats/effect/metrics/CpuStarvationMbean.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/metrics/JvmCpuStarvationMetrics.scala b/core/jvm/src/main/scala/cats/effect/metrics/JvmCpuStarvationMetrics.scala index 6e8e579b73..9a8dc6e6c7 100644 --- a/core/jvm/src/main/scala/cats/effect/metrics/JvmCpuStarvationMetrics.scala +++ b/core/jvm/src/main/scala/cats/effect/metrics/JvmCpuStarvationMetrics.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/tracing/TracingPlatform.scala b/core/jvm/src/main/scala/cats/effect/tracing/TracingPlatform.scala index c5df75f259..8a19056990 100644 --- a/core/jvm/src/main/scala/cats/effect/tracing/TracingPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/tracing/TracingPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/FiberMonitor.scala b/core/jvm/src/main/scala/cats/effect/unsafe/FiberMonitor.scala index c43ec462f3..d2990b44e0 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/FiberMonitor.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/FiberMonitor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,9 @@ package cats.effect package unsafe import cats.effect.tracing.TracingConstants -import cats.effect.unsafe.ref.WeakReference import scala.concurrent.ExecutionContext -import java.util.concurrent.ConcurrentLinkedQueue - /** * A slightly more involved implementation of an unordered bag used for tracking asynchronously * suspended fiber instances on the JVM. This bag is backed by an array of synchronized @@ -49,11 +46,10 @@ private[effect] sealed class FiberMonitor( private[this] val compute: WorkStealingThreadPool[_] ) extends FiberMonitorShared { - private[this] final val BagReferences = - new ConcurrentLinkedQueue[WeakReference[WeakBag[Runnable]]] + private[this] final val BagReferences = new WeakList[WeakBag[Runnable]] private[this] final val Bags = ThreadLocal.withInitial { () => val bag = new WeakBag[Runnable]() - BagReferences.offer(new WeakReference(bag)) + BagReferences.prepend(bag) bag } @@ -199,15 +195,12 @@ private[effect] sealed class FiberMonitor( private[this] def foreignFibers(): Map[IOFiber[_], Trace] = { val foreign = Map.newBuilder[IOFiber[_], Trace] - BagReferences.iterator().forEachRemaining { bagRef => - val bag = bagRef.get() - if (bag ne null) { - val _ = bag.synchronizationPoint.get() - bag.forEach { - case fiber: IOFiber[_] if !fiber.isDone => - foreign += (fiber.asInstanceOf[IOFiber[Any]] -> fiber.captureTrace()) - case _ => () - } + BagReferences.foreach { bag => + val _ = bag.synchronizationPoint.get() + bag.forEach { + case fiber: IOFiber[_] if !fiber.isDone => + foreign += (fiber.asInstanceOf[IOFiber[Any]] -> fiber.captureTrace()) + case _ => () } } diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala index 2ccc274a51..018c7932d9 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala index 12c81bc5dc..9412fbdbfe 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala index c7ac83cd7b..4263100a98 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/LocalQueue.scala b/core/jvm/src/main/scala/cats/effect/unsafe/LocalQueue.scala index c83c34b5ec..8b0a6b0e91 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/LocalQueue.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/LocalQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/ScalQueue.scala b/core/jvm/src/main/scala/cats/effect/unsafe/ScalQueue.scala index 5da44bf354..c1cb1d86dc 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/ScalQueue.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/ScalQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala b/core/jvm/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala index 458823b300..a48fd0edf4 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala b/core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala index a958076cea..bbb853b947 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/SleepSystem.scala b/core/jvm/src/main/scala/cats/effect/unsafe/SleepSystem.scala index 541335e62d..46ffa909e3 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/SleepSystem.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/SleepSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/TimerHeap.scala b/core/jvm/src/main/scala/cats/effect/unsafe/TimerHeap.scala index 963712cae2..4ae344085c 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/TimerHeap.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/TimerHeap.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala b/core/jvm/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala index 631f1a45bb..fa8628919c 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 c19093c008..9c31f4a448 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSampler.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSampler.scala index d15573f2e4..6347db1870 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSampler.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSampler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSamplerMBean.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSamplerMBean.scala index 249457c5ba..40676b6ff5 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSamplerMBean.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/ComputePoolSamplerMBean.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTrigger.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTrigger.scala index b901dd2393..24838b381d 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTrigger.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTrigger.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTriggerMBean.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTriggerMBean.scala index d9bbc38d6f..0e9c7d8114 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTriggerMBean.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LiveFiberSnapshotTriggerMBean.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSampler.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSampler.scala index d9a420a2ab..aee9df5d3b 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSampler.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSampler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSamplerMBean.scala b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSamplerMBean.scala index c2cc6a2065..964ada2328 100644 --- a/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSamplerMBean.scala +++ b/core/jvm/src/main/scala/cats/effect/unsafe/metrics/LocalQueueSamplerMBean.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/FileDescriptorPoller.scala b/core/native/src/main/scala/cats/effect/FileDescriptorPoller.scala index 28deff9bbf..b4a99feb47 100644 --- a/core/native/src/main/scala/cats/effect/FileDescriptorPoller.scala +++ b/core/native/src/main/scala/cats/effect/FileDescriptorPoller.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/IOApp.scala b/core/native/src/main/scala/cats/effect/IOApp.scala index 6268cf9b33..540c6b0c38 100644 --- a/core/native/src/main/scala/cats/effect/IOApp.scala +++ b/core/native/src/main/scala/cats/effect/IOApp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/IOCompanionPlatform.scala b/core/native/src/main/scala/cats/effect/IOCompanionPlatform.scala index 9b3b3f9e40..e4b4157c21 100644 --- a/core/native/src/main/scala/cats/effect/IOCompanionPlatform.scala +++ b/core/native/src/main/scala/cats/effect/IOCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/IOPlatform.scala b/core/native/src/main/scala/cats/effect/IOPlatform.scala index 5c0eeee4f3..1cb2313f24 100644 --- a/core/native/src/main/scala/cats/effect/IOPlatform.scala +++ b/core/native/src/main/scala/cats/effect/IOPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/Platform.scala b/core/native/src/main/scala/cats/effect/Platform.scala index 9fbedaf859..a92dbcd460 100644 --- a/core/native/src/main/scala/cats/effect/Platform.scala +++ b/core/native/src/main/scala/cats/effect/Platform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/Signal.scala b/core/native/src/main/scala/cats/effect/Signal.scala index b380dea64e..6d678211df 100644 --- a/core/native/src/main/scala/cats/effect/Signal.scala +++ b/core/native/src/main/scala/cats/effect/Signal.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/metrics/NativeCpuStarvationMetrics.scala b/core/native/src/main/scala/cats/effect/metrics/NativeCpuStarvationMetrics.scala index bc2c849e58..8263751437 100644 --- a/core/native/src/main/scala/cats/effect/metrics/NativeCpuStarvationMetrics.scala +++ b/core/native/src/main/scala/cats/effect/metrics/NativeCpuStarvationMetrics.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/tracing/TracingConstants.scala b/core/native/src/main/scala/cats/effect/tracing/TracingConstants.scala index e42aabe733..885e7ea83a 100644 --- a/core/native/src/main/scala/cats/effect/tracing/TracingConstants.scala +++ b/core/native/src/main/scala/cats/effect/tracing/TracingConstants.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/tracing/TracingPlatform.scala b/core/native/src/main/scala/cats/effect/tracing/TracingPlatform.scala index 53679d406f..9e8c116f15 100644 --- a/core/native/src/main/scala/cats/effect/tracing/TracingPlatform.scala +++ b/core/native/src/main/scala/cats/effect/tracing/TracingPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/EpollSystem.scala b/core/native/src/main/scala/cats/effect/unsafe/EpollSystem.scala index 28c7f4afb3..9874edb58e 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/EpollSystem.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/EpollSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/EventLoopExecutorScheduler.scala b/core/native/src/main/scala/cats/effect/unsafe/EventLoopExecutorScheduler.scala index f0be84c399..e9ea74a5e3 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/EventLoopExecutorScheduler.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/EventLoopExecutorScheduler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala b/core/native/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala index f38fb411b7..f1ebf234c4 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/FiberMonitorPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala index 53bea4f0c6..39e06b5d69 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeBuilderPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala index 6b270106a3..075fed2b7e 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala index d681685256..b49de91103 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/IORuntimeConfigCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/KqueueSystem.scala b/core/native/src/main/scala/cats/effect/unsafe/KqueueSystem.scala index 8f5febc439..3a26a4eb6d 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/KqueueSystem.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/KqueueSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/PollingExecutorScheduler.scala b/core/native/src/main/scala/cats/effect/unsafe/PollingExecutorScheduler.scala index a430a236f4..c37a16677f 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/PollingExecutorScheduler.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/PollingExecutorScheduler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala b/core/native/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala index 6bbd99f4b0..de7aee4774 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/SchedulerCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/native/src/main/scala/cats/effect/unsafe/SleepSystem.scala b/core/native/src/main/scala/cats/effect/unsafe/SleepSystem.scala index f6afe5ca26..cea4bca406 100644 --- a/core/native/src/main/scala/cats/effect/unsafe/SleepSystem.scala +++ b/core/native/src/main/scala/cats/effect/unsafe/SleepSystem.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/ContState.scala b/core/shared/src/main/scala/cats/effect/ContState.scala index e6519f6c26..6208075699 100644 --- a/core/shared/src/main/scala/cats/effect/ContState.scala +++ b/core/shared/src/main/scala/cats/effect/ContState.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/CpuStarvationCheck.scala b/core/shared/src/main/scala/cats/effect/CpuStarvationCheck.scala index 92cfe9e14b..6a9bbe9c6f 100644 --- a/core/shared/src/main/scala/cats/effect/CpuStarvationCheck.scala +++ b/core/shared/src/main/scala/cats/effect/CpuStarvationCheck.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/ExitCode.scala b/core/shared/src/main/scala/cats/effect/ExitCode.scala index 241ab5a983..49a4ca9495 100644 --- a/core/shared/src/main/scala/cats/effect/ExitCode.scala +++ b/core/shared/src/main/scala/cats/effect/ExitCode.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/IO.scala b/core/shared/src/main/scala/cats/effect/IO.scala index dc380fd5de..7138a0b915 100644 --- a/core/shared/src/main/scala/cats/effect/IO.scala +++ b/core/shared/src/main/scala/cats/effect/IO.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1310,7 +1310,7 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits with TuplePara lift(k(resume)) flatMap { case Right(a) => G.pure(a) case Left(Some(fin)) => G.onCancel(poll(get), lift(fin)) - case Left(None) => poll(get) + case Left(None) => get } } } diff --git a/core/shared/src/main/scala/cats/effect/IODeferred.scala b/core/shared/src/main/scala/cats/effect/IODeferred.scala index a64481b910..64665277e7 100644 --- a/core/shared/src/main/scala/cats/effect/IODeferred.scala +++ b/core/shared/src/main/scala/cats/effect/IODeferred.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,6 @@ private final class IODeferred[A] extends Deferred[IO, A] { def complete(a: A): IO[Boolean] = IO { if (cell.compareAndSet(initial, IO.pure(a))) { val _ = callbacks(Right(a)) - callbacks.clear() // avoid leaks true } else { false diff --git a/core/shared/src/main/scala/cats/effect/IOFiber.scala b/core/shared/src/main/scala/cats/effect/IOFiber.scala index e00631a525..68b905635b 100644 --- a/core/shared/src/main/scala/cats/effect/IOFiber.scala +++ b/core/shared/src/main/scala/cats/effect/IOFiber.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1082,15 +1082,11 @@ private final class IOFiber[A]( outcome = oc - try { - if (!callbacks(oc) && runtime.config.reportUnhandledFiberErrors) { - oc match { - case Outcome.Errored(e) => currentCtx.reportFailure(e) - case _ => () - } + if (!callbacks(oc) && runtime.config.reportUnhandledFiberErrors) { + oc match { + case Outcome.Errored(e) => currentCtx.reportFailure(e) + case _ => () } - } finally { - callbacks.clear() /* avoid leaks */ } /* diff --git a/core/shared/src/main/scala/cats/effect/IOLocal.scala b/core/shared/src/main/scala/cats/effect/IOLocal.scala index 0675fe042a..64fdb26d44 100644 --- a/core/shared/src/main/scala/cats/effect/IOLocal.scala +++ b/core/shared/src/main/scala/cats/effect/IOLocal.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/LiftIO.scala b/core/shared/src/main/scala/cats/effect/LiftIO.scala index 7b3d0728c5..26a089c4c4 100644 --- a/core/shared/src/main/scala/cats/effect/LiftIO.scala +++ b/core/shared/src/main/scala/cats/effect/LiftIO.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/ResourceApp.scala b/core/shared/src/main/scala/cats/effect/ResourceApp.scala index c0f4b452b5..cb2003f7bc 100644 --- a/core/shared/src/main/scala/cats/effect/ResourceApp.scala +++ b/core/shared/src/main/scala/cats/effect/ResourceApp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/SyncIO.scala b/core/shared/src/main/scala/cats/effect/SyncIO.scala index 38d57b643c..7ea67fd474 100644 --- a/core/shared/src/main/scala/cats/effect/SyncIO.scala +++ b/core/shared/src/main/scala/cats/effect/SyncIO.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/Trace.scala b/core/shared/src/main/scala/cats/effect/Trace.scala index 976307049e..aa6f08829b 100644 --- a/core/shared/src/main/scala/cats/effect/Trace.scala +++ b/core/shared/src/main/scala/cats/effect/Trace.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/implicits.scala b/core/shared/src/main/scala/cats/effect/implicits.scala index 59cd3f1863..412252433d 100644 --- a/core/shared/src/main/scala/cats/effect/implicits.scala +++ b/core/shared/src/main/scala/cats/effect/implicits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/instances/AllInstances.scala b/core/shared/src/main/scala/cats/effect/instances/AllInstances.scala index d145248dbf..356f594c3d 100644 --- a/core/shared/src/main/scala/cats/effect/instances/AllInstances.scala +++ b/core/shared/src/main/scala/cats/effect/instances/AllInstances.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/instances/package.scala b/core/shared/src/main/scala/cats/effect/instances/package.scala index fdc8df6e22..d75ced6867 100644 --- a/core/shared/src/main/scala/cats/effect/instances/package.scala +++ b/core/shared/src/main/scala/cats/effect/instances/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationMetrics.scala b/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationMetrics.scala index 1b0e51e2cd..920311d7f9 100644 --- a/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationMetrics.scala +++ b/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationMetrics.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationWarningMetrics.scala b/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationWarningMetrics.scala index 65194deae1..ea74970865 100644 --- a/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationWarningMetrics.scala +++ b/core/shared/src/main/scala/cats/effect/metrics/CpuStarvationWarningMetrics.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/package.scala b/core/shared/src/main/scala/cats/effect/package.scala index 0af80f188e..0270eae439 100644 --- a/core/shared/src/main/scala/cats/effect/package.scala +++ b/core/shared/src/main/scala/cats/effect/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/syntax/AllSyntax.scala b/core/shared/src/main/scala/cats/effect/syntax/AllSyntax.scala index 92b9c8e44f..7d3b2d0c46 100644 --- a/core/shared/src/main/scala/cats/effect/syntax/AllSyntax.scala +++ b/core/shared/src/main/scala/cats/effect/syntax/AllSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/syntax/package.scala b/core/shared/src/main/scala/cats/effect/syntax/package.scala index cac307ff51..0ac617609f 100644 --- a/core/shared/src/main/scala/cats/effect/syntax/package.scala +++ b/core/shared/src/main/scala/cats/effect/syntax/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/tracing/RingBuffer.scala b/core/shared/src/main/scala/cats/effect/tracing/RingBuffer.scala index 2a7ac48387..1585c0d6c9 100644 --- a/core/shared/src/main/scala/cats/effect/tracing/RingBuffer.scala +++ b/core/shared/src/main/scala/cats/effect/tracing/RingBuffer.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/tracing/Tracing.scala b/core/shared/src/main/scala/cats/effect/tracing/Tracing.scala index e92ac74c66..3a6acb3f00 100644 --- a/core/shared/src/main/scala/cats/effect/tracing/Tracing.scala +++ b/core/shared/src/main/scala/cats/effect/tracing/Tracing.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/tracing/TracingEvent.scala b/core/shared/src/main/scala/cats/effect/tracing/TracingEvent.scala index a098fcfd77..ea4acf4cc9 100644 --- a/core/shared/src/main/scala/cats/effect/tracing/TracingEvent.scala +++ b/core/shared/src/main/scala/cats/effect/tracing/TracingEvent.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/FiberMonitorShared.scala b/core/shared/src/main/scala/cats/effect/unsafe/FiberMonitorShared.scala index 1515d0d2d5..ced924dcdb 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/FiberMonitorShared.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/FiberMonitorShared.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/IORuntime.scala b/core/shared/src/main/scala/cats/effect/unsafe/IORuntime.scala index 416fd342c3..d32caa0c47 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/IORuntime.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/IORuntime.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeBuilder.scala b/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeBuilder.scala index 08e0d2dcf1..f0e44169bf 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeBuilder.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeBuilder.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeConfig.scala b/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeConfig.scala index a7fc3f9ab6..546ffbe852 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeConfig.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/IORuntimeConfig.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,18 @@ final case class IORuntimeConfig private ( val cpuStarvationCheckInitialDelay: Duration, val cpuStarvationCheckThreshold: Double) { + require(autoYieldThreshold > 1, s"Auto yield threshold $autoYieldThreshold must be > 1") + require( + cancelationCheckThreshold > 0, + s"Cancelation check threshold $cancelationCheckThreshold must be > 0") + require( + (autoYieldThreshold % cancelationCheckThreshold) == 0, + s"Auto yield threshold $autoYieldThreshold must be a multiple of cancelation check threshold $cancelationCheckThreshold" + ) + require( + cpuStarvationCheckThreshold > 0, + s"CPU starvation check threshold $cpuStarvationCheckThreshold must be > 0") + private[unsafe] def this(cancelationCheckThreshold: Int, autoYieldThreshold: Int) = this( cancelationCheckThreshold, @@ -224,25 +236,17 @@ object IORuntimeConfig extends IORuntimeConfigCompanionPlatform { cpuStarvationCheckInitialDelay: Duration, cpuStarvationCheckThreshold: Double ): IORuntimeConfig = { - if (autoYieldThreshold % cancelationCheckThreshold == 0) - if (cpuStarvationCheckThreshold > 0) - new IORuntimeConfig( - cancelationCheckThreshold, - autoYieldThreshold, - enhancedExceptions, - 1 << Math.round(Math.log(traceBufferSize.toDouble) / Math.log(2)).toInt, - shutdownHookTimeout, - reportUnhandledFiberErrors, - cpuStarvationCheckInterval, - cpuStarvationCheckInitialDelay, - cpuStarvationCheckThreshold - ) - else - throw new AssertionError( - s"CPU starvation check threshold $cpuStarvationCheckThreshold must be > 0") - else - throw new AssertionError( - s"Auto yield threshold $autoYieldThreshold must be a multiple of cancelation check threshold $cancelationCheckThreshold") + new IORuntimeConfig( + cancelationCheckThreshold, + autoYieldThreshold, + enhancedExceptions, + 1 << Math.round(Math.log(traceBufferSize.toDouble) / Math.log(2)).toInt, + shutdownHookTimeout, + reportUnhandledFiberErrors, + cpuStarvationCheckInterval, + cpuStarvationCheckInitialDelay, + cpuStarvationCheckThreshold + ) } def apply( diff --git a/core/shared/src/main/scala/cats/effect/unsafe/Scheduler.scala b/core/shared/src/main/scala/cats/effect/unsafe/Scheduler.scala index 953fa04883..f1be750cf4 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/Scheduler.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/Scheduler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/StripedHashtable.scala b/core/shared/src/main/scala/cats/effect/unsafe/StripedHashtable.scala index 3910b8d42f..15d4c81110 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/StripedHashtable.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/StripedHashtable.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/ThreadSafeHashtable.scala b/core/shared/src/main/scala/cats/effect/unsafe/ThreadSafeHashtable.scala index 89fea53811..8f1d592255 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/ThreadSafeHashtable.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/ThreadSafeHashtable.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/WeakBag.scala b/core/shared/src/main/scala/cats/effect/unsafe/WeakBag.scala index d80de664bc..b57bdfe1cb 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/WeakBag.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/WeakBag.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/cats/effect/unsafe/WeakList.scala b/core/shared/src/main/scala/cats/effect/unsafe/WeakList.scala new file mode 100644 index 0000000000..16789d771b --- /dev/null +++ b/core/shared/src/main/scala/cats/effect/unsafe/WeakList.scala @@ -0,0 +1,188 @@ +/* + * Copyright 2020-2024 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cats.effect.unsafe + +import cats.effect.unsafe.ref.{ReferenceQueue, WeakReference} + +import scala.annotation.tailrec + +import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference} + +import WeakList.Node + +private final class WeakList[A] extends AtomicReference[Node[A]] { + head => + + private[this] val queue = new ReferenceQueue[A]() + private[this] val allowedToPack = new AtomicBoolean(true) + private[this] var gcCount = 0 + + /** + * Prepends a value to the list + */ + def prepend(a: A): Unit = { + packIfNeeded() + + val newHead = new Node(a, queue) + + @tailrec + def loop(): Unit = { + val currentHead = head.get() + newHead.setNext(currentHead) + + if (!head.compareAndSet(currentHead, newHead)) + loop() + } + + loop() + } + + def foreach(f: A => Unit): Unit = { + var currentNode = head.get() + while (currentNode ne null) { + val a = currentNode.get() + if (a != null) f(a) + currentNode = currentNode.getNext() + } + } + + private[this] def packIfNeeded(): Unit = + if (allowedToPack.compareAndSet(true, false)) { + try { + var gcCount = this.gcCount // local copy + + var shouldPack = false + while (queue.poll() != null) { + gcCount += 1 + if ((gcCount > 0) && (gcCount & (gcCount - 1)) == 0) { // positive power of 2 + shouldPack = true + // don't break the loop, keep draining queue + } + } + + if (shouldPack) { + // b/c pack is aggressive, it may clean nodes before we poll them out of the queue + // in that case, gcCount may go negative + gcCount -= pack(gcCount) + } + + this.gcCount = gcCount + } finally { + allowedToPack.set(true) + } + } + + private[this] def pack(bound: Int): Int = { + val got = head.get() + if (got ne null) + got.packHead(bound, 0, this) + else + 0 + } + + override def toString(): String = s"WeakList(${get()})" + +} + +private object WeakList { + + private[WeakList] final class Node[A](a: A, queue: ReferenceQueue[A]) + extends WeakReference(a, queue) { + private[this] var _next: Node[A] = _ // `next` clashes with field in superclass (?) + + def getNext(): Node[A] = _next + + def setNext(next: Node[A]): Unit = { + this._next = next + } + + /** + * Packs this head node + */ + @tailrec + def packHead(bound: Int, removed: Int, root: WeakList[A]): Int = { + val next = this._next // local copy + + if (get() == null) { + if (root.compareAndSet(this, next)) { + if (next == null) { + // bottomed out + removed + 1 + } else { + // note this can cause the bound to go negative, which is fine + next.packHead(bound - 1, removed + 1, root) + } + } else { + val prev = root.get() + if ((prev != null) && (prev.getNext() eq this)) { + // prev is our new parent, we are its tail + this.packTail(bound, removed, prev) + } else if (next != null) { // we were unable to remove ourselves, but we can still pack our tail + next.packTail(bound - 1, removed, this) + } else { + removed + } + } + } else { + if (next == null) { + // bottomed out + removed + } else { + if (bound > 0) + next.packTail(bound - 1, removed, this) + else + removed + } + } + } + + /** + * Packs this non-head node + */ + @tailrec + private def packTail(bound: Int, removed: Int, prev: Node[A]): Int = { + val next = this._next // local copy + + if (get() == null) { + // We own the pack lock, so it is safe to write `next`. It will be published to subsequent packs via the lock. + // Concurrent readers ie `WeakList#foreach` may read a stale value for `next` still pointing to this node. + // This is okay b/c the new `next` (this node's tail) is still reachable via the old `next` (this node). + prev.setNext(next) + if (next == null) { + // bottomed out + removed + 1 + } else { + // note this can cause the bound to go negative, which is fine + next.packTail(bound - 1, removed + 1, prev) + } + } else { + if (next == null) { + // bottomed out + removed + } else { + if (bound > 0) + next.packTail(bound - 1, removed, this) + else + removed + } + } + } + + override def toString(): String = s"Node(${get()}, ${_next})" + } + +} diff --git a/core/shared/src/main/scala/cats/effect/unsafe/implicits.scala b/core/shared/src/main/scala/cats/effect/unsafe/implicits.scala index c10666a567..51e6173255 100644 --- a/core/shared/src/main/scala/cats/effect/unsafe/implicits.scala +++ b/core/shared/src/main/scala/cats/effect/unsafe/implicits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/docs/core/native-image.md b/docs/core/native-image.md index 3a29e30c9a..0d033c68e9 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.5.3", + libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.4", 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 caaa355101..0d5118e7d7 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.5.3", + libraryDependencies += "org.typelevel" %%% "cats-effect" % "3.5.4", Compile / mainClass := Some("com.example.Main") ) diff --git a/docs/core/test-runtime.md b/docs/core/test-runtime.md index cb5adfb29d..b321d5ffb4 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.5.3" % Test +libraryDependencies += "org.typelevel" %% "cats-effect-testkit" % "3.5.4" % Test ``` ## Example diff --git a/docs/faq.md b/docs/faq.md index 6235ec4cf3..7057aabca0 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -9,7 +9,7 @@ title: FAQ ```scala-cli //> using scala "2.13.8" -//> using dep "org.typelevel::cats-effect::3.5.3" +//> using dep "org.typelevel::cats-effect::3.5.4" import cats.effect._ diff --git a/docs/getting-started.md b/docs/getting-started.md index 4241e338dd..3259cbc652 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.5.3" +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.4" ``` 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.5.3` +import $ivy.`org.typelevel::cats-effect:3.5.4` import cats.effect.unsafe.implicits._ import cats.effect.IO diff --git a/docs/migration-guide.md b/docs/migration-guide.md index e4d19a705c..1f1eb9f6c2 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -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.3", -"org.typelevel" %% "cats-effect-std" % "3.5.3", -"org.typelevel" %% "cats-effect" % "3.5.3", +"org.typelevel" %% "cats-effect-kernel" % "3.5.4", +"org.typelevel" %% "cats-effect-std" % "3.5.4", +"org.typelevel" %% "cats-effect" % "3.5.4", ``` - `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.5.3", ++ "org.typelevel" %% "cats-effect" % "3.5.4", //... ) ``` diff --git a/docs/std/mapref.md b/docs/std/mapref.md index cff4da3eb8..39fee799fd 100644 --- a/docs/std/mapref.md +++ b/docs/std/mapref.md @@ -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.3" +//> using lib "org.typelevel::cats-effect::3.5.4" import cats.effect.IO import cats.effect.std.MapRef diff --git a/docs/std/ref.md b/docs/std/ref.md index 35f3c7c62a..e4d69dc230 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.5.3" +//> using lib "org.typelevel::cats-effect::3.5.4" import cats.effect.{IO, IOApp, Sync} import cats.effect.kernel.Ref diff --git a/docs/tutorial.md b/docs/tutorial.md index f567c7fb81..b48bab5a8f 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -42,25 +42,23 @@ running the code snippets in this tutorial, it is recommended to use the same ```scala name := "cats-effect-tutorial" -version := "3.5.3" +version := "3.5.4" -scalaVersion := "2.13.11" +scalaVersion := "2.13.13" -libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.3" withSources() withJavadoc() +libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.4" withSources() withJavadoc() scalacOptions ++= Seq( "-feature", "-deprecation", "-unchecked", - "-language:postfixOps" ) ``` - -Also make sure that you use a recent version of `sbt`, _e.g._ `1.9.7`. You can set +Also make sure that you use a recent version of `sbt`, _e.g._ `1.9.8`. You can set the `sbt` version in `project/build.properties` file: ```scala -sbt.version=1.9.7 +sbt.version=1.9.8 ``` Almost all code snippets in this tutorial can be pasted and compiled right in diff --git a/example/js-native/src/main/scala/cats/effect/example/Example.scala b/example/js-native/src/main/scala/cats/effect/example/Example.scala index a0953358e0..5bf5bc8ec4 100644 --- a/example/js-native/src/main/scala/cats/effect/example/Example.scala +++ b/example/js-native/src/main/scala/cats/effect/example/Example.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/example/jvm/src/main/scala/cats/effect/example/Example.scala b/example/jvm/src/main/scala/cats/effect/example/Example.scala index 874371db94..1314a81306 100644 --- a/example/jvm/src/main/scala/cats/effect/example/Example.scala +++ b/example/jvm/src/main/scala/cats/effect/example/Example.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/graalvm-example/src/main/scala/cats/effect/example/Example.scala b/graalvm-example/src/main/scala/cats/effect/example/Example.scala index 32b9ef945d..012773e172 100644 --- a/graalvm-example/src/main/scala/cats/effect/example/Example.scala +++ b/graalvm-example/src/main/scala/cats/effect/example/Example.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/FreeSyncGenerators.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/FreeSyncGenerators.scala index f4c6b80f31..c7a1675b62 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/FreeSyncGenerators.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/FreeSyncGenerators.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/Generators.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/Generators.scala index d47e874717..bc2bbb796b 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/Generators.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/Generators.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/PureConcGenerators.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/PureConcGenerators.scala index e0b30d6e96..c6162d20d4 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/PureConcGenerators.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/PureConcGenerators.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestContext.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestContext.scala index aa1e616a8e..6ba6a26a1b 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestContext.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestContext.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestInstances.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestInstances.scala index 8605202e35..097bbec12c 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestInstances.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TestInstances.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TimeT.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TimeT.scala index 1f9c607263..a74a18e241 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TimeT.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/TimeT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/freeEval.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/freeEval.scala index 7c5650b052..1e07223fab 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/freeEval.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/freeEval.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/package.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/package.scala index 95d21f5100..eb9305d25d 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/package.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/pure.scala b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/pure.scala index 45d350aa51..c784639d3f 100644 --- a/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/pure.scala +++ b/kernel-testkit/shared/src/main/scala/cats/effect/kernel/testkit/pure.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/js-native/src/main/scala/cats/effect/kernel/SyncRef.scala b/kernel/js-native/src/main/scala/cats/effect/kernel/SyncRef.scala index c24b409615..46363fe91e 100644 --- a/kernel/js-native/src/main/scala/cats/effect/kernel/SyncRef.scala +++ b/kernel/js-native/src/main/scala/cats/effect/kernel/SyncRef.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/js/src/main/scala/cats/effect/kernel/AsyncPlatform.scala b/kernel/js/src/main/scala/cats/effect/kernel/AsyncPlatform.scala index 73619396b1..7bfb993e2f 100644 --- a/kernel/js/src/main/scala/cats/effect/kernel/AsyncPlatform.scala +++ b/kernel/js/src/main/scala/cats/effect/kernel/AsyncPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/js/src/main/scala/cats/effect/kernel/ClockPlatform.scala b/kernel/js/src/main/scala/cats/effect/kernel/ClockPlatform.scala index b84533fec6..d7da30e376 100644 --- a/kernel/js/src/main/scala/cats/effect/kernel/ClockPlatform.scala +++ b/kernel/js/src/main/scala/cats/effect/kernel/ClockPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/js/src/main/scala/cats/effect/kernel/ResourcePlatform.scala b/kernel/js/src/main/scala/cats/effect/kernel/ResourcePlatform.scala index f71fcf716b..765ea5fd9f 100644 --- a/kernel/js/src/main/scala/cats/effect/kernel/ResourcePlatform.scala +++ b/kernel/js/src/main/scala/cats/effect/kernel/ResourcePlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/jvm-native/src/main/scala/cats/effect/kernel/ClockPlatform.scala b/kernel/jvm-native/src/main/scala/cats/effect/kernel/ClockPlatform.scala index fe3a5bc330..e569bf71bf 100644 --- a/kernel/jvm-native/src/main/scala/cats/effect/kernel/ClockPlatform.scala +++ b/kernel/jvm-native/src/main/scala/cats/effect/kernel/ClockPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/jvm/src/main/scala/cats/effect/kernel/AsyncPlatform.scala b/kernel/jvm/src/main/scala/cats/effect/kernel/AsyncPlatform.scala index e4997d8283..7ae56b24bf 100644 --- a/kernel/jvm/src/main/scala/cats/effect/kernel/AsyncPlatform.scala +++ b/kernel/jvm/src/main/scala/cats/effect/kernel/AsyncPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/jvm/src/main/scala/cats/effect/kernel/ResourcePlatform.scala b/kernel/jvm/src/main/scala/cats/effect/kernel/ResourcePlatform.scala index 2433241823..6e90db9ac0 100644 --- a/kernel/jvm/src/main/scala/cats/effect/kernel/ResourcePlatform.scala +++ b/kernel/jvm/src/main/scala/cats/effect/kernel/ResourcePlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/jvm/src/main/scala/cats/effect/kernel/SyncRef.scala b/kernel/jvm/src/main/scala/cats/effect/kernel/SyncRef.scala index 0642288299..1e6b7d30b9 100644 --- a/kernel/jvm/src/main/scala/cats/effect/kernel/SyncRef.scala +++ b/kernel/jvm/src/main/scala/cats/effect/kernel/SyncRef.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/native/src/main/scala/cats/effect/kernel/AsyncPlatform.scala b/kernel/native/src/main/scala/cats/effect/kernel/AsyncPlatform.scala index e82d985252..698e5cd8ad 100644 --- a/kernel/native/src/main/scala/cats/effect/kernel/AsyncPlatform.scala +++ b/kernel/native/src/main/scala/cats/effect/kernel/AsyncPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/native/src/main/scala/cats/effect/kernel/ResourcePlatform.scala b/kernel/native/src/main/scala/cats/effect/kernel/ResourcePlatform.scala index d7de5b383e..0e682d813b 100644 --- a/kernel/native/src/main/scala/cats/effect/kernel/ResourcePlatform.scala +++ b/kernel/native/src/main/scala/cats/effect/kernel/ResourcePlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala-2.12/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala b/kernel/shared/src/main/scala-2.12/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala index ce4fb283c8..28572f2a51 100644 --- a/kernel/shared/src/main/scala-2.12/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala +++ b/kernel/shared/src/main/scala-2.12/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala-2.13/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala b/kernel/shared/src/main/scala-2.13/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala index 8c05ea61ac..f682de16c3 100644 --- a/kernel/shared/src/main/scala-2.13/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala +++ b/kernel/shared/src/main/scala-2.13/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala-3/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala b/kernel/shared/src/main/scala-3/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala index 8c05ea61ac..f682de16c3 100644 --- a/kernel/shared/src/main/scala-3/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala +++ b/kernel/shared/src/main/scala-3/cats/effect/kernel/syntax/GenTemporalSyntaxCompat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Async.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Async.scala index 861a7fea3e..655f7018f1 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Async.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Async.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,12 +71,12 @@ trait Async[F[_]] extends AsyncPlatform[F] with Sync[F] with Temporal[F] { * the callback will be effective! All subsequent invocations will be silently dropped. * * The process of registering the callback itself is suspended in `F` (the outer `F` of - * `F[Either[Option[G[Unit]], A]]`). + * `F[Either[Option[F[Unit]], A]]`). * * The effect returns `Either[Option[F[Unit]], A]` where: * - right side `A` is an immediate result of computation (callback invocation will be * dropped); - * - left side `Option[F[Unit]] `is an optional finalizer to be run in the event that the + * - left side `Option[F[Unit]]` is an optional finalizer to be run in the event that the * fiber running `asyncCheckAttempt(k)` is canceled. * * Also, note that `asyncCheckAttempt` is uncancelable during its registration. @@ -139,7 +139,7 @@ trait Async[F[_]] extends AsyncPlatform[F] with Sync[F] with Temporal[F] { * This function can be thought of as a safer, lexically-constrained version of `Promise`, * where `IO` is like a safer, lazy version of `Future`. * - * Also, note that `async` is uncancelable during its registration. + * Also, note that `async_` is uncancelable during its registration. * * @see * [[async]] for more generic version providing a finalizer diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/CancelScope.scala b/kernel/shared/src/main/scala/cats/effect/kernel/CancelScope.scala index 4f61de96a9..0e8a790f7c 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/CancelScope.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/CancelScope.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Clock.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Clock.scala index 2fdef6645b..9e2dd99526 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Clock.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Clock.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Cont.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Cont.scala index 8ec07d3066..8ff2e992db 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Cont.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Cont.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Deferred.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Deferred.scala index 50b31929ad..7e9e5ee668 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Deferred.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Deferred.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Fiber.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Fiber.scala index 6452bebb69..b3ddc5e942 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Fiber.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Fiber.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/GenConcurrent.scala b/kernel/shared/src/main/scala/cats/effect/kernel/GenConcurrent.scala index 6da5142b74..d39d90d47f 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/GenConcurrent.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/GenConcurrent.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/GenSpawn.scala b/kernel/shared/src/main/scala/cats/effect/kernel/GenSpawn.scala index 9d322c065a..d4d8d9ab6e 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/GenSpawn.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/GenSpawn.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/GenTemporal.scala b/kernel/shared/src/main/scala/cats/effect/kernel/GenTemporal.scala index 27cdacbf68..56d6d0d270 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/GenTemporal.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/GenTemporal.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/MiniSemaphore.scala b/kernel/shared/src/main/scala/cats/effect/kernel/MiniSemaphore.scala index 80c028d42b..bd59fff362 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/MiniSemaphore.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/MiniSemaphore.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/MonadCancel.scala b/kernel/shared/src/main/scala/cats/effect/kernel/MonadCancel.scala index 2213dd0174..2cf8178184 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/MonadCancel.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/MonadCancel.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Outcome.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Outcome.scala index 0cf4b584be..2b633dce37 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Outcome.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Outcome.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/ParallelF.scala b/kernel/shared/src/main/scala/cats/effect/kernel/ParallelF.scala index 5e3663908b..990e98c46e 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/ParallelF.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/ParallelF.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Poll.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Poll.scala index c2485747ef..738cbc206d 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Poll.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Poll.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Ref.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Ref.scala index 46148f70ef..b04cd3c469 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Ref.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Ref.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala index 6169d4ee3a..6ee94c2dbc 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala index dc63120be7..30ed9206f3 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/Unique.scala b/kernel/shared/src/main/scala/cats/effect/kernel/Unique.scala index 479825481d..a052ffa52b 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/Unique.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/Unique.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/implicits.scala b/kernel/shared/src/main/scala/cats/effect/kernel/implicits.scala index afbc85c563..4940b8c8f6 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/implicits.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/implicits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/instances/AllInstances.scala b/kernel/shared/src/main/scala/cats/effect/kernel/instances/AllInstances.scala index ab196f857d..8ed64ab79c 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/instances/AllInstances.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/instances/AllInstances.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/instances/GenSpawnInstances.scala b/kernel/shared/src/main/scala/cats/effect/kernel/instances/GenSpawnInstances.scala index f75c928243..3d44b439f4 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/instances/GenSpawnInstances.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/instances/GenSpawnInstances.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/instances/package.scala b/kernel/shared/src/main/scala/cats/effect/kernel/instances/package.scala index cdf1003173..8010073956 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/instances/package.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/instances/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/package.scala b/kernel/shared/src/main/scala/cats/effect/kernel/package.scala index 0f677e87df..244fdf03b4 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/package.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AllSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AllSyntax.scala index 29846eb099..2f9d85cbb9 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AllSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AllSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AsyncSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AsyncSyntax.scala index 906c371cac..bbf1ff071d 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AsyncSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/AsyncSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ClockSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ClockSyntax.scala index 9726cc7661..efae3d98aa 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ClockSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ClockSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenConcurrentSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenConcurrentSyntax.scala index 4fceb6c91a..f0d0c44233 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenConcurrentSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenConcurrentSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenSpawnSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenSpawnSyntax.scala index b5fbc46683..68e673c622 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenSpawnSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenSpawnSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenTemporalSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenTemporalSyntax.scala index cbe7c48fd3..2801daa98f 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenTemporalSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/GenTemporalSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/MonadCancelSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/MonadCancelSyntax.scala index 5a842492e5..41e5a929a2 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/MonadCancelSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/MonadCancelSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ResourceSyntax.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ResourceSyntax.scala index 8ee66a4ff3..cae535cb7b 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ResourceSyntax.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/ResourceSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/package.scala b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/package.scala index 457b66cfef..2c6a6330f5 100644 --- a/kernel/shared/src/main/scala/cats/effect/kernel/syntax/package.scala +++ b/kernel/shared/src/main/scala/cats/effect/kernel/syntax/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala b/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala index 78f614db3f..0536eb3c03 100644 --- a/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala +++ b/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/AsyncLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/AsyncLaws.scala index 981d9122e3..2cf7a1e122 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/AsyncLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/AsyncLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/AsyncTests.scala b/laws/shared/src/main/scala/cats/effect/laws/AsyncTests.scala index 7b1bbd7de1..6557d02b5d 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/AsyncTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/AsyncTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/ClockLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/ClockLaws.scala index e92f8f3bfa..e420222393 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/ClockLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/ClockLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/ClockTests.scala b/laws/shared/src/main/scala/cats/effect/laws/ClockTests.scala index dc5178c8ba..2443249a34 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/ClockTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/ClockTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/GenSpawnLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/GenSpawnLaws.scala index 0189c77c8f..44c7e25b0c 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/GenSpawnLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/GenSpawnLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/GenSpawnTests.scala b/laws/shared/src/main/scala/cats/effect/laws/GenSpawnTests.scala index 8ab1a64495..ad5a9a182b 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/GenSpawnTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/GenSpawnTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/GenTemporalLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/GenTemporalLaws.scala index 89ab5d6675..adfc53cd42 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/GenTemporalLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/GenTemporalLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/GenTemporalTests.scala b/laws/shared/src/main/scala/cats/effect/laws/GenTemporalTests.scala index c63579943c..3964827309 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/GenTemporalTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/GenTemporalTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/IsEq.scala b/laws/shared/src/main/scala/cats/effect/laws/IsEq.scala index cc4342b1cd..0429ae3e00 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/IsEq.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/IsEq.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/MonadCancelLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/MonadCancelLaws.scala index f2cae18b3c..14f6698612 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/MonadCancelLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/MonadCancelLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/MonadCancelTests.scala b/laws/shared/src/main/scala/cats/effect/laws/MonadCancelTests.scala index f91ebfa3d5..62729c5c71 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/MonadCancelTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/MonadCancelTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/SyncLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/SyncLaws.scala index 210422b54e..b97bd1fffc 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/SyncLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/SyncLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/SyncTests.scala b/laws/shared/src/main/scala/cats/effect/laws/SyncTests.scala index 269a40a995..0d5e250abf 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/SyncTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/SyncTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/Tolerance.scala b/laws/shared/src/main/scala/cats/effect/laws/Tolerance.scala index 311b5bbf13..4fa5be3f21 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/Tolerance.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/Tolerance.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/UniqueLaws.scala b/laws/shared/src/main/scala/cats/effect/laws/UniqueLaws.scala index 17b9ea5180..703a878420 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/UniqueLaws.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/UniqueLaws.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/UniqueTests.scala b/laws/shared/src/main/scala/cats/effect/laws/UniqueTests.scala index f44b470ef6..3009eed7ff 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/UniqueTests.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/UniqueTests.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/main/scala/cats/effect/laws/package.scala b/laws/shared/src/main/scala/cats/effect/laws/package.scala index bebe22e2bf..228bc9ec98 100644 --- a/laws/shared/src/main/scala/cats/effect/laws/package.scala +++ b/laws/shared/src/main/scala/cats/effect/laws/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/BaseSpec.scala b/laws/shared/src/test/scala/cats/effect/BaseSpec.scala index ec3e295e3a..8cffc5d793 100644 --- a/laws/shared/src/test/scala/cats/effect/BaseSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/BaseSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala b/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala index bb8feba90d..92ee1e355e 100644 --- a/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala index 0008bc8e16..6977c5b073 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala index 5968c63467..a1e4c127b3 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala index 9e38a3fd87..e5662cb4c4 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala index db0ab59f59..0aaad68f86 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala index 5403c86f98..fa5e6c15d0 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala index ba237839f4..b1d2fefdde 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala index bd549763c2..7d66ecff8a 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala index df2ac2631a..906277b7b0 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala index 843a58c8d2..40af10706b 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala index 4f3fd18438..46dd37fb80 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala index 6b8e5f67c1..6e67eb1f53 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala index 6e4de84133..5b367f4037 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala index 4df3ba5724..79401a66be 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala index 4c16bcd7d7..821b581950 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala index 406d781f51..6a676f59e3 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala index ad44aa909c..bddaa5cf4d 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala index c8e6b1d73e..0b393219ee 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala index 59c5fea21f..de9298e9bc 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala index 3663c442ac..7658826d3b 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala b/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala index 218eccc97d..d3d8418298 100644 --- a/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/project/CI.scala b/project/CI.scala index 31f2bbdd1d..5e42c26114 100644 --- a/project/CI.scala +++ b/project/CI.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/project/Common.scala b/project/Common.scala index fa9578c8a1..b10cde586c 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ object Common extends AutoPlugin { override def projectSettings = Seq( headerLicense := Some( - HeaderLicense.ALv2(s"${startYear.value.get}-2023", organizationName.value) + HeaderLicense.ALv2(s"${startYear.value.get}-2024", organizationName.value) ), tlVersionIntroduced ++= { if (crossProjectPlatform.?.value.contains(NativePlatform)) diff --git a/project/JSEnv.scala b/project/JSEnv.scala index 5b3bb273d8..70e1e70a44 100644 --- a/project/JSEnv.scala +++ b/project/JSEnv.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js-native/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala b/std/js-native/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala index 6dd25335eb..01328f1ae9 100644 --- a/std/js-native/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala +++ b/std/js-native/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js-native/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala b/std/js-native/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala index eee9334aaf..2d3edfeac5 100644 --- a/std/js-native/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala +++ b/std/js-native/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js/src/main/scala/cats/effect/std/Console.scala b/std/js/src/main/scala/cats/effect/std/Console.scala index 09a4404494..0362fde1d0 100644 --- a/std/js/src/main/scala/cats/effect/std/Console.scala +++ b/std/js/src/main/scala/cats/effect/std/Console.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js/src/main/scala/cats/effect/std/DispatcherPlatform.scala b/std/js/src/main/scala/cats/effect/std/DispatcherPlatform.scala index 4aba11336c..c504aead30 100644 --- a/std/js/src/main/scala/cats/effect/std/DispatcherPlatform.scala +++ b/std/js/src/main/scala/cats/effect/std/DispatcherPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala b/std/js/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala index 7479bb4215..b55a26e7a6 100644 --- a/std/js/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala +++ b/std/js/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/js/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala b/std/js/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala index 47b1e01fea..cb8e5ee6a2 100644 --- a/std/js/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala +++ b/std/js/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm-native/src/main/scala/cats/effect/std/Console.scala b/std/jvm-native/src/main/scala/cats/effect/std/Console.scala index 34ecc0fb0f..062c22b47a 100644 --- a/std/jvm-native/src/main/scala/cats/effect/std/Console.scala +++ b/std/jvm-native/src/main/scala/cats/effect/std/Console.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm-native/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala b/std/jvm-native/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala index f5be9ca580..80ba0baa0a 100644 --- a/std/jvm-native/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala +++ b/std/jvm-native/src/main/scala/cats/effect/std/EnvCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala b/std/jvm/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala index 299786bc36..5719fd6729 100644 --- a/std/jvm/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala +++ b/std/jvm/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm/src/main/scala/cats/effect/std/DispatcherPlatform.scala b/std/jvm/src/main/scala/cats/effect/std/DispatcherPlatform.scala index e3e142489b..284b45b403 100644 --- a/std/jvm/src/main/scala/cats/effect/std/DispatcherPlatform.scala +++ b/std/jvm/src/main/scala/cats/effect/std/DispatcherPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala b/std/jvm/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala index 1b93ec0838..d8f3e5513d 100644 --- a/std/jvm/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala +++ b/std/jvm/src/main/scala/cats/effect/std/MapRefCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala b/std/jvm/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala index 3382a71bcc..0583939ce9 100644 --- a/std/jvm/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala +++ b/std/jvm/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/jvm/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala b/std/jvm/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala index 1a15a049a5..7794e51440 100644 --- a/std/jvm/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala +++ b/std/jvm/src/main/scala/cats/effect/std/UUIDGenCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/native/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala b/std/native/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala index a9d0abb116..e17ead8f05 100644 --- a/std/native/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala +++ b/std/native/src/main/scala/cats/effect/std/ConsoleCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/native/src/main/scala/cats/effect/std/DispatcherPlatform.scala b/std/native/src/main/scala/cats/effect/std/DispatcherPlatform.scala index c22fa36290..fe176cd03b 100644 --- a/std/native/src/main/scala/cats/effect/std/DispatcherPlatform.scala +++ b/std/native/src/main/scala/cats/effect/std/DispatcherPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/native/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala b/std/native/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala index 6589e53a4d..b8c8cbcb72 100644 --- a/std/native/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala +++ b/std/native/src/main/scala/cats/effect/std/SecureRandomCompanionPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/AtomicCell.scala b/std/shared/src/main/scala/cats/effect/std/AtomicCell.scala index 51094381b1..3ecf447ca2 100644 --- a/std/shared/src/main/scala/cats/effect/std/AtomicCell.scala +++ b/std/shared/src/main/scala/cats/effect/std/AtomicCell.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Backpressure.scala b/std/shared/src/main/scala/cats/effect/std/Backpressure.scala index a81076dbed..d90cd73470 100644 --- a/std/shared/src/main/scala/cats/effect/std/Backpressure.scala +++ b/std/shared/src/main/scala/cats/effect/std/Backpressure.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala b/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala index 9277fbd4e3..38aaedd020 100644 --- a/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala +++ b/std/shared/src/main/scala/cats/effect/std/ConsoleCrossPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/CountDownLatch.scala b/std/shared/src/main/scala/cats/effect/std/CountDownLatch.scala index bb27ca6c27..201bdeabe9 100644 --- a/std/shared/src/main/scala/cats/effect/std/CountDownLatch.scala +++ b/std/shared/src/main/scala/cats/effect/std/CountDownLatch.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/CyclicBarrier.scala b/std/shared/src/main/scala/cats/effect/std/CyclicBarrier.scala index 6d55cd7168..e097632a44 100644 --- a/std/shared/src/main/scala/cats/effect/std/CyclicBarrier.scala +++ b/std/shared/src/main/scala/cats/effect/std/CyclicBarrier.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Dequeue.scala b/std/shared/src/main/scala/cats/effect/std/Dequeue.scala index a98fa18430..aef920368d 100644 --- a/std/shared/src/main/scala/cats/effect/std/Dequeue.scala +++ b/std/shared/src/main/scala/cats/effect/std/Dequeue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Dispatcher.scala b/std/shared/src/main/scala/cats/effect/std/Dispatcher.scala index 48a77506cb..b96b20fd34 100644 --- a/std/shared/src/main/scala/cats/effect/std/Dispatcher.scala +++ b/std/shared/src/main/scala/cats/effect/std/Dispatcher.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,27 @@ package cats.effect.std -import cats.effect.kernel.{Async, Outcome, Resource} +import cats.{Applicative, MonadThrow} +import cats.effect.kernel.{ + Async, + Concurrent, + Cont, + Deferred, + MonadCancel, + MonadCancelThrow, + Outcome, + Ref, + Resource, + Spawn, + Sync +} +import cats.effect.kernel.syntax.all._ import cats.effect.std.Dispatcher.parasiticEC import cats.syntax.all._ import scala.annotation.tailrec -import scala.collection.mutable import scala.concurrent.{ExecutionContext, Future, Promise} -import scala.util.{Failure, Success} +import scala.util.Failure import java.util.concurrent.ThreadLocalRandom import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference} @@ -71,10 +84,13 @@ trait Dispatcher[F[_]] extends DispatcherPlatform[F] { */ def unsafeRunAndForget[A](fa: F[A]): Unit = unsafeToFuture(fa).onComplete { - case Failure(ex) => ex.printStackTrace() + case Failure(ex) => reportFailure(ex) case _ => () }(parasiticEC) + protected def reportFailure(t: Throwable): Unit = + t.printStackTrace() + // package-private because it's just an internal utility which supports specific implementations // anyone who needs this type of thing should use unsafeToFuture and then onComplete private[std] def unsafeRunAsync[A](fa: F[A])(cb: Either[Throwable, A] => Unit): Unit = @@ -91,11 +107,6 @@ object Dispatcher { private[this] val Cpus: Int = Runtime.getRuntime().availableProcessors() - private[this] val Noop: () => Unit = () => () - private[this] val Open: () => Unit = () => () - - private[this] val Completed: Either[Throwable, Unit] = Right(()) - @deprecated( message = "use '.parallel' or '.sequential' instead; the former corresponds to the current semantics of '.apply'", @@ -107,16 +118,14 @@ object Dispatcher { * exits, all active effects will be canceled, and attempts to submit new effects will throw * an exception. */ - def parallel[F[_]: Async]: Resource[F, Dispatcher[F]] = - parallel[F](await = false) + def parallel[F[_]: Async]: Resource[F, Dispatcher[F]] = parallel(false) /** * Create a [[Dispatcher]] that can be used within a resource scope. Once the resource scope * exits, all active effects will be canceled, and attempts to submit new effects will throw * an exception. */ - def sequential[F[_]: Async]: Resource[F, Dispatcher[F]] = - sequential[F](await = false) + def sequential[F[_]: Async]: Resource[F, Dispatcher[F]] = sequential(false) /** * Create a [[Dispatcher]] that can be used within a resource scope. Once the resource scope @@ -154,7 +163,7 @@ object Dispatcher { * - false - cancel the active fibers */ def parallel[F[_]: Async](await: Boolean): Resource[F, Dispatcher[F]] = - apply(Mode.Parallel, await) + impl[F](true, await, true) /** * Create a [[Dispatcher]] that can be used within a resource scope. Once the resource scope @@ -190,240 +199,483 @@ object Dispatcher { * - false - cancel the active fiber */ def sequential[F[_]: Async](await: Boolean): Resource[F, Dispatcher[F]] = - apply(Mode.Sequential, await) - - private[this] def apply[F[_]](mode: Mode, await: Boolean)( - implicit F: Async[F]): Resource[F, Dispatcher[F]] = { - final case class Registration(action: F[Unit], prepareCancel: F[Unit] => Unit) - extends AtomicBoolean(true) - - sealed trait CancelState - case object CancelInit extends CancelState - final case class CanceledNoToken(promise: Promise[Unit]) extends CancelState - final case class CancelToken(cancelToken: () => Future[Unit]) extends CancelState - - val (workers, makeFork) = - mode match { - case Mode.Parallel => - (Cpus, Supervisor[F](await).map(s => s.supervise(_: F[Unit]).map(_.cancel))) - - case Mode.Sequential => - ( - 1, - Resource - .pure[F, F[Unit] => F[F[Unit]]]((_: F[Unit]).as(F.unit).handleError(_ => F.unit))) - } - - for { - fork <- makeFork + impl[F](false, await, false) + + // TODO decide if we want other people to use this + private[std] def sequentialCancelable[F[_]: Async]( + await: Boolean): Resource[F, Dispatcher[F]] = + impl[F](false, await, true) + + /* + * There are three fundamental modes here: sequential, parallel, and sequential-cancelable. There + * is very little overlap in semantics between the three apart from the submission side. The whole thing is split up into + * a submission queue with impure enqueue and cancel functions which is drained by the `Worker` and an + * internal execution protocol which also involves a queue. The `Worker` encapsulates all of the + * race conditions and negotiations with impure code, while the `Executor` manages running the + * tasks with appropriate semantics. In parallel mode, we shard the `Worker`s according to the + * number of CPUs and select a random queue (in impure code) as a target. This reduces contention + * at the cost of ordering, which is not guaranteed in parallel mode. With the sequential modes, there + * is only a single worker. + * + * On the impure side, the queue bit is the easy part: it's just a `UnsafeUnbounded` (queue) which + * accepts Registration(s). It's easiest to think of this a bit like an actor model, where the + * `Worker` is the actor and the enqueue is the send. Whenever we send a unit of work, that + * message has an `AtomicReference` which allows us to back-propagate a cancelation action. That + * cancelation action can be used in impure code by sending it back to us using the Finalizer + * message. There are certain race conditions involved in canceling work on the queue and work + * which is in the process of being taken off the queue, and those race conditions are negotiated + * between the impure code and the `Worker`. + * + * On the pure side, the three different `Executor`s are very distinct. In parallel mode, it's easy: + * we have a separate `Supervisor` which doesn't respawn actions, and we use that supervisor to + * spawn a new fiber for each task unit. Cancelation in this mode is easy: we just cancel the fiber. + * + * Sequential mode is the simplest of all: all work is executed in-place and cannot be canceled. + * The cancelation action in all cases is simply `unit` because the impure submission will not be + * seen until after the work is completed *anyway*, so there's no point in being fancy. + * + * For sequential-cancelable mode, we spawn a *single* executor fiber on the main supervisor (which respawns). + * This fiber is paired with a pure unbounded queue and a shutoff latch. New work is placed on the + * queue, which the fiber takes from in order and executes in-place. If the work self-cancels or + * errors, the executor will be restarted. In the case of external cancelation, we shut off the + * latch (to hold new work), drain the entire work queue into a scratch space, then cancel the + * executor fiber in-place so long as we're sure it's actively working on the target task. Once + * that cancelation completes (which will ultimately restart the executor fiber), we re-fill the + * queue and unlock the latch to allow new work (from the `Worker`). + */ + private[this] def impl[F[_]: Async]( + parallel: Boolean, + await: Boolean, + cancelable: Boolean): Resource[F, Dispatcher[F]] = { + val always = Some((_: Outcome[F, Throwable, _]) => true) + + // the outer supervisor is for the worker fibers + // the inner supervisor is for tasks (if parallel) and finalizers + Supervisor[F](await = await, checkRestart = always) flatMap { supervisor => + // we only need this flag to raise the IllegalStateException after closure (Supervisor can't do it for us) + + val termination = Resource.make(Sync[F].delay(new AtomicBoolean(false)))(doneR => + Sync[F].delay(doneR.set(true))) + + val awaitTermination = Resource.make(Concurrent[F].deferred[Unit])(_.complete(()).void) + + (awaitTermination, termination) flatMapN { (terminationLatch, doneR) => + val executorF = + if (parallel) + Executor.parallel[F](await) + else if (cancelable) + Executor.sequential(supervisor) + else + Resource.pure[F, Executor[F]](Executor.inplace[F]) + + // note this scopes the executors *outside* the workers, meaning the workers shut down first + // I think this is what we want, since it avoids enqueue race conditions + executorF flatMap { executor => + val workerF = Worker[F](executor, terminationLatch) + val workersF = + if (parallel) + workerF.replicateA(Cpus).map(_.toArray) + else + workerF.map(w => Array(w)) + + workersF evalMap { workers => + Async[F].executionContext flatMap { ec => + val launchAll = 0.until(workers.length).toList traverse_ { i => + supervisor.supervise(workers(i).run) + } - latches <- Resource.eval(F delay { - val latches = new Array[AtomicReference[() => Unit]](workers) - var i = 0 - while (i < workers) { - latches(i) = new AtomicReference(Noop) - i += 1 - } - latches - }) - states <- Resource.eval(F delay { - val states = Array.ofDim[AtomicReference[List[Registration]]](workers, workers) - var i = 0 - while (i < workers) { - var j = 0 - while (j < workers) { - states(i)(j) = new AtomicReference(Nil) - j += 1 - } - i += 1 - } - states - }) - ec <- Resource.eval(F.executionContext) - - // supervisor for the main loop, which needs to always restart unless the Supervisor itself is canceled - // critically, inner actions can be canceled without impacting the loop itself - supervisor <- Supervisor[F](await, Some((_: Outcome[F, Throwable, _]) => true)) - - _ <- { - def step( - state: Array[AtomicReference[List[Registration]]], - await: F[Unit], - doneR: AtomicBoolean): F[Unit] = - for { - done <- F.delay(doneR.get()) - regs <- F delay { - val buffer = mutable.ListBuffer.empty[Registration] - var i = 0 - while (i < workers) { - val st = state(i) - if (st.get() ne null) { - val list = if (done) st.getAndSet(null) else st.getAndSet(Nil) - if ((list ne null) && (list ne Nil)) { - buffer ++= list.reverse // FIFO order here is a form of fairness + launchAll.as(new Dispatcher[F] { + def unsafeToFutureCancelable[A](fa: F[A]): (Future[A], () => Future[Unit]) = { + def inner[E](fe: F[E], result: Promise[E], finalizer: Boolean) + : () => Future[Unit] = { + if (doneR.get()) { + throw new IllegalStateException("Dispatcher already closed") + } + + val stateR = new AtomicReference[RegState[F]](RegState.Unstarted) + + // forward atomicity guarantees onto promise completion + val promisory = MonadCancel[F] uncancelable { poll => + // invalidate the cancel action when we're done + val completeState = Sync[F].delay { + stateR.getAndSet(RegState.Completed) match { + case st: RegState.CancelRequested[_] => + // we already have a cancel, must complete it: + st.latch.success(()) + () + + case RegState.Completed => + throw new AssertionError("unexpected Completed state") + + case _ => + () + } + } + poll(fe.guarantee(completeState)).redeemWith( + e => Sync[F].delay(result.failure(e)), + a => Sync[F].delay(result.success(a))) + } + + val worker = + if (parallel) + workers(ThreadLocalRandom.current().nextInt(Cpus)) + else + workers(0) + + if (finalizer) { + worker.queue.unsafeOffer(Registration.Finalizer(promisory.void)) + + // cannot cancel a cancel + () => Future.failed(new UnsupportedOperationException) + } else { + val reg = new Registration.Primary(promisory.void, stateR) + worker.queue.unsafeOffer(reg) + + @tailrec + def cancel(): Future[Unit] = { + stateR.get() match { + case RegState.Unstarted => + val latch = Promise[Unit]() + + reg.action = null.asInstanceOf[F[Unit]] + + if (stateR.compareAndSet( + RegState.Unstarted, + RegState.CancelRequested(latch))) { + latch.future + } else { + cancel() + } + + case r: RegState.Running[_] => + val cancel = r.cancel // indirection needed for Scala 2.12 + + val latch = Promise[Unit]() + val _ = inner(cancel, latch, true) + latch.future + + case r: RegState.CancelRequested[_] => + r.latch.future + + case RegState.Completed => + Future.successful(()) + } + } + + cancel _ + } } - } - i += 1 - } - buffer.toList - } - _ <- - if (regs.isEmpty) { - await - } else { - regs traverse_ { - case r @ Registration(action, prepareCancel) => - val supervise: F[Unit] = - fork(action).flatMap(cancel => F.delay(prepareCancel(cancel))) - - // Check for task cancelation before executing. - F.delay(r.get()).ifM(supervise, F.delay(prepareCancel(F.unit))) + val result = Promise[A]() + (result.future, inner(fa, result, false)) } - } - } yield () - - def dispatcher( - doneR: AtomicBoolean, - latch: AtomicReference[() => Unit], - state: Array[AtomicReference[List[Registration]]]): F[Unit] = { - - val await = - F.async_[Unit] { cb => - if (!latch.compareAndSet(Noop, () => cb(Completed))) { - // state was changed between when we last set the latch and now; complete the callback immediately - cb(Completed) - } - } - - F.delay(latch.set(Noop)) *> // reset latch - // if we're marked as done, yield immediately to give other fibers a chance to shut us down - // we might loop on this a few times since we're marked as done before the supervisor is canceled - F.delay(doneR.get()).ifM(F.cede, step(state, await, doneR)) - } - 0.until(workers).toList traverse_ { n => - Resource.eval(F.delay(new AtomicBoolean(false))) flatMap { doneR => - val latch = latches(n) - val worker = dispatcher(doneR, latch, states(n)) - val release = F.delay(latch.getAndSet(Open)()) - Resource.make(supervisor.supervise(worker)) { _ => - F.delay(doneR.set(true)) *> step(states(n), F.unit, doneR) *> release + override def reportFailure(t: Throwable): Unit = + ec.reportFailure(t) + }) } } } } - } yield { - new Dispatcher[F] { - override def unsafeRunAndForget[A](fa: F[A]): Unit = { - unsafeToFutureCancelable(fa) - ._1 - .onComplete { - case Failure(ex) => ec.reportFailure(ex) - case _ => () - }(parasiticEC) - } + } + } + + private sealed abstract class RegState[+F[_]] extends Product with Serializable - def unsafeToFutureCancelable[E](fe: F[E]): (Future[E], () => Future[Unit]) = { - val promise = Promise[E]() + private object RegState { + case object Unstarted extends RegState[Nothing] + final case class Running[F[_]](cancel: F[Unit]) extends RegState[F] + final case class CancelRequested[F[_]](latch: Promise[Unit]) extends RegState[F] + case object Completed extends RegState[Nothing] + } + + private sealed abstract class Registration[F[_]] - val action = fe - .flatMap(e => F.delay(promise.success(e))) - .handleErrorWith(t => F.delay(promise.failure(t))) - .void + private object Registration { + final class Primary[F[_]](var action: F[Unit], val stateR: AtomicReference[RegState[F]]) + extends Registration[F] - val cancelState = new AtomicReference[CancelState](CancelInit) + final case class Finalizer[F[_]](action: F[Unit]) extends Registration[F] - def registerCancel(token: F[Unit]): Unit = { - val cancelToken = () => unsafeToFuture(token) + final case class PoisonPill[F[_]]() extends Registration[F] + } - @tailrec - def loop(): Unit = { - val state = cancelState.get() - state match { - case CancelInit => - if (!cancelState.compareAndSet(state, CancelToken(cancelToken))) { - loop() + // the signal is just a skolem for the atomic references; we never actually run it + private final class Worker[F[_]: Async]( + val queue: UnsafeAsyncQueue[F, Registration[F]], + supervisor: Supervisor[F], + executor: Executor[F], + terminationLatch: Deferred[F, Unit]) { + + private[this] val doneR = new AtomicBoolean(false) + + def run: F[Unit] = { + val step = queue.take flatMap { + case reg: Registration.Primary[F] => + Sync[F] defer { + reg.stateR.get() match { + case RegState.Unstarted => + val action = reg.action + + if (action == null) { + // this corresponds to a memory race where we see action's write before stateR's + val check = Spawn[F].cede *> Sync[F].delay(reg.stateR.get()) + check.iterateWhile(_ == RegState.Unstarted).flatMap { + case cr @ RegState.CancelRequested(latch) => + Sync[F].delay { + if (reg.stateR.compareAndSet(cr, RegState.Completed)) { + latch.success(()) + () + } else { + val s = reg.stateR.get() + throw new AssertionError(s"d => $s") + } + } + case s => + MonadThrow[F].raiseError[Unit](new AssertionError(s"a => $s")) } - case CanceledNoToken(promise) => - if (!cancelState.compareAndSet(state, CancelToken(cancelToken))) { - loop() - } else { - cancelToken().onComplete { - case Success(_) => promise.success(()) - case Failure(ex) => promise.failure(ex) - }(ec) + } else { + + executor(action) { cancelF => + Sync[F] defer { + if (reg + .stateR + .compareAndSet(RegState.Unstarted, RegState.Running(cancelF))) { + Applicative[F].unit + } else { + reg.stateR.get() match { + case cr @ RegState.CancelRequested(latch) => + if (reg.stateR.compareAndSet(cr, RegState.Running(cancelF))) { + supervisor + .supervise(cancelF.guarantee(Sync[F].delay { + latch.success(()) + () + })) + .void + } else { + reg.stateR.get() match { + case RegState.Completed => + Applicative[F].unit + case s => + throw new AssertionError(s"e => $s") + } + } + + case RegState.Completed => + Applicative[F].unit + + case s => + throw new AssertionError(s"b => $s") + } + } + } } - case _ => () - } - } + } - loop() - } + case s @ (RegState.Running(_) | RegState.Completed) => + throw new AssertionError(s"c => $s") - @tailrec - def enqueue(state: AtomicReference[List[Registration]], reg: Registration): Unit = { - val curr = state.get() - if (curr eq null) { - throw new IllegalStateException("dispatcher already shutdown") - } else { - val next = reg :: curr - if (!state.compareAndSet(curr, next)) enqueue(state, reg) + case RegState.CancelRequested(latch) => + Sync[F].delay(latch.success(())).void } } - val (state, lt) = if (workers > 1) { - val rand = ThreadLocalRandom.current() - val dispatcher = rand.nextInt(workers) - val inner = rand.nextInt(workers) + case Registration.Finalizer(action) => + supervisor.supervise(action).void.voidError - (states(dispatcher)(inner), latches(dispatcher)) - } else { - (states(0)(0), latches(0)) - } + case Registration.PoisonPill() => + Sync[F].delay(doneR.set(true)) + } - val reg = Registration(action, registerCancel _) - enqueue(state, reg) + // we're poisoned *first* but our supervisor is killed *last* + // when this happens, we just block on the termination latch to + // avoid weirdness. there's still a small gap even then, so we + // toss in a cede to avoid starvation pathologies + Sync[F].delay(doneR.get()).ifM(terminationLatch.get >> Spawn[F].cede, step >> run) + } + } + + private object Worker { + + def apply[F[_]: Async]( + executor: Executor[F], + terminationLatch: Deferred[F, Unit]): Resource[F, Worker[F]] = { + // we make a new supervisor just for cancelation actions + Supervisor[F](false) flatMap { supervisor => + val initF = Sync[F].delay( + new Worker[F]( + new UnsafeAsyncQueue[F, Registration[F]](), + supervisor, + executor, + terminationLatch)) + + Resource.make(initF)(w => Sync[F].delay(w.queue.unsafeOffer(Registration.PoisonPill()))) + } + } + } + + private abstract class Executor[F[_]] { + def apply(task: F[Unit])(registerCancel: F[Unit] => F[Unit]): F[Unit] + } + + private object Executor { - if (lt.get() ne Open) { - val f = lt.getAndSet(Open) - f() + // default sequential executor (ignores cancelation) + def inplace[F[_]: Concurrent]: Executor[F] = + new Executor[F] { + def apply(task: F[Unit])(registerCancel: F[Unit] => F[Unit]): F[Unit] = { + Concurrent[F].deferred[Unit].flatMap { d => + (registerCancel(d.get) *> task).guarantee(d.complete(()).void) } + } + } + + // sequential executor which respects cancelation (at the cost of additional overhead); not used + def sequential[F[_]: Concurrent](supervisor: Supervisor[F]): Resource[F, Executor[F]] = { + sealed trait TaskState extends Product with Serializable + + object TaskState { + final case class Ready(task: F[Unit]) extends TaskState + case object Executing extends TaskState + final case class Canceling(latch: Deferred[F, Unit]) extends TaskState + case object Dead extends TaskState + } - val cancel = { () => - reg.lazySet(false) - - @tailrec - def loop(): Future[Unit] = { - val state = cancelState.get() - state match { - case CancelInit => - val promise = Promise[Unit]() - if (!cancelState.compareAndSet(state, CanceledNoToken(promise))) { - loop() - } else { - promise.future + Resource.eval(Queue.unbounded[F, Ref[F, TaskState]]) flatMap { tasks => + // knock it out of the task taking + val evict = Concurrent[F].ref[TaskState](TaskState.Dead).flatMap(tasks.offer(_)) + + Resource.make(Concurrent[F].ref(false))(r => r.set(true) >> evict) evalMap { doneR => + Concurrent[F].ref[Option[Deferred[F, Unit]]](None) flatMap { shutoff => + val step = tasks.take flatMap { taskR => + taskR.getAndSet(TaskState.Executing) flatMap { + case TaskState.Ready(task) => + task guarantee { + taskR.getAndSet(TaskState.Dead) flatMap { + // if we finished during cancelation, we need to catch it before it kills us + case TaskState.Canceling(latch) => latch.complete(()).void + case _ => Applicative[F].unit + } } - case CanceledNoToken(promise) => - promise.future - case CancelToken(cancelToken) => - cancelToken() + + // Executing should be impossible + case TaskState.Executing | TaskState.Canceling(_) | TaskState.Dead => + Applicative[F].unit } } - loop() + lazy val loop: F[Unit] = doneR.get.ifM(Applicative[F].unit, step >> loop) + val spawnExecutor = supervisor.supervise(loop) + + spawnExecutor flatMap { fiber => + Concurrent[F].ref(fiber) map { fiberR => + new Executor[F] { + def apply(task: F[Unit])(registerCancel: F[Unit] => F[Unit]): F[Unit] = { + Concurrent[F].ref[TaskState](TaskState.Ready(task)) flatMap { taskR => + val cancelF = + Concurrent[F].deferred[Unit] flatMap { cancelLatch => + taskR flatModify { + case TaskState.Ready(_) | TaskState.Dead => + (TaskState.Dead, Applicative[F].unit) + + case TaskState.Canceling(cancelLatch) => + (TaskState.Canceling(cancelLatch), cancelLatch.get) + + case TaskState.Executing => + // we won the race for cancelation and it's already executing + val eff = for { + // lock the door + latch <- Concurrent[F].deferred[Unit] + _ <- shutoff.set(Some(latch)) + + // drain the task queue + scratch <- tasks.tryTakeN(None) + + // double check that execution didn't finish while we drained + _ <- cancelLatch.tryGet flatMap { + case Some(_) => + Applicative[F].unit + + case None => + for { + // kill the current executor + _ <- fiberR.get.flatMap(_.cancel) + + // restore all of the tasks + _ <- scratch.traverse_(tasks.offer(_)) + + // start a new fiber + _ <- spawnExecutor.flatMap(fiberR.set(_)) + + // allow everyone else back in + _ <- latch.complete(()) + _ <- shutoff.set(None) + } yield () + } + + _ <- cancelLatch.complete(()) + } yield () + + (TaskState.Canceling(cancelLatch), eff) + } + } + + // in rare cases, this can create mutual ordering issues with quickly enqueued tasks + val optBlock = shutoff.get flatMap { + case Some(latch) => latch.get + case None => Applicative[F].unit + } + + optBlock >> tasks.offer(taskR) >> registerCancel(cancelF) + } + } + } + } + } } - - (promise.future, cancel) } } } + + def parallel[F[_]: Concurrent](await: Boolean): Resource[F, Executor[F]] = + Supervisor[F](await = await) map { supervisor => + new Executor[F] { + def apply(task: F[Unit])(registerCancel: F[Unit] => F[Unit]): F[Unit] = + supervisor.supervise(task).flatMap(fiber => registerCancel(fiber.cancel)) + } + } } - private sealed trait Mode extends Product with Serializable + private val RightUnit: Right[Nothing, Unit] = Right(()) + + // MPSC assumption + private final class UnsafeAsyncQueue[F[_]: Async, A] + extends AtomicReference[Either[Throwable, Unit] => Unit](null) { latchR => + + private[this] val buffer = new UnsafeUnbounded[A]() + + def unsafeOffer(a: A): Unit = { + val _ = buffer.put(a) + val back = latchR.get() + if (back ne null) back(RightUnit) + } + + def take: F[A] = Async[F].cont[Unit, A] { + new Cont[F, Unit, A] { + def apply[G[_]: MonadCancelThrow] = { (k, get, lift) => + val takeG = lift(Sync[F].delay(buffer.take())) + val setLatchG = lift(Sync[F].delay(latchR.set(k))) + val unsetLatchG = lift(Sync[F].delay(latchR.lazySet(null))) + + takeG.handleErrorWith { _ => // emptiness is reported as a FailureSignal error + setLatchG *> (takeG <* unsetLatchG).handleErrorWith { _ => // double-check + get *> unsetLatchG *> lift(take) // recurse + } + } + } + + } + } - private object Mode { - case object Parallel extends Mode - case object Sequential extends Mode } } diff --git a/std/shared/src/main/scala/cats/effect/std/Env.scala b/std/shared/src/main/scala/cats/effect/std/Env.scala index 038e5ad8fe..560f302bd9 100644 --- a/std/shared/src/main/scala/cats/effect/std/Env.scala +++ b/std/shared/src/main/scala/cats/effect/std/Env.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/FailureSignal.scala b/std/shared/src/main/scala/cats/effect/std/FailureSignal.scala index 33987619ba..f9ae0bb759 100644 --- a/std/shared/src/main/scala/cats/effect/std/FailureSignal.scala +++ b/std/shared/src/main/scala/cats/effect/std/FailureSignal.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Hotswap.scala b/std/shared/src/main/scala/cats/effect/std/Hotswap.scala index 05a39a9303..2be9642122 100644 --- a/std/shared/src/main/scala/cats/effect/std/Hotswap.scala +++ b/std/shared/src/main/scala/cats/effect/std/Hotswap.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/MapRef.scala b/std/shared/src/main/scala/cats/effect/std/MapRef.scala index abedb22e8d..17b8d4ac97 100644 --- a/std/shared/src/main/scala/cats/effect/std/MapRef.scala +++ b/std/shared/src/main/scala/cats/effect/std/MapRef.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Mutex.scala b/std/shared/src/main/scala/cats/effect/std/Mutex.scala index dd37867b21..dfb5d8d52c 100644 --- a/std/shared/src/main/scala/cats/effect/std/Mutex.scala +++ b/std/shared/src/main/scala/cats/effect/std/Mutex.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,6 +87,12 @@ object Mutex { )( implicit F: Concurrent[F] ) extends Mutex[F] { + + // This is a variant of the Craig, Landin, and Hagersten + // (CLH) queue lock. Queue nodes (called cells below) + // are `Deferred`s, so fibers can suspend and wake up + // (instead of spinning, like in the original algorithm). + // Awakes whoever is waiting for us with the next cell in the queue. private def awakeCell( ourCell: ConcurrentImpl.WaitingCell[F], diff --git a/std/shared/src/main/scala/cats/effect/std/PQueue.scala b/std/shared/src/main/scala/cats/effect/std/PQueue.scala index 4ef532a570..06d641cc22 100644 --- a/std/shared/src/main/scala/cats/effect/std/PQueue.scala +++ b/std/shared/src/main/scala/cats/effect/std/PQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Queue.scala b/std/shared/src/main/scala/cats/effect/std/Queue.scala index 81e5c827eb..2871f895ca 100644 --- a/std/shared/src/main/scala/cats/effect/std/Queue.scala +++ b/std/shared/src/main/scala/cats/effect/std/Queue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -820,52 +820,58 @@ object Queue { val size: F[Int] = F.delay(buffer.size()) - val take: F[A] = F defer { - try { - // attempt to take from the buffer. if it's empty, this will raise an exception - F.pure(buffer.take()) - } catch { - case FailureSignal => - // buffer was empty - // capture the fact that our retry succeeded and the value we were able to take - var received = false - var result: A = null.asInstanceOf[A] - - // a latch to block until some offerer wakes us up - val wait = F.async[Unit] { k => - F delay { - // register ourselves as a listener for offers - val clear = takers.put(k) - - try { - // now that we're registered, retry the take - result = buffer.take() - - // it worked! clear out our listener - clear() - // we got a result, so received should be true now - received = true - - // complete our own callback. see notes in offer about raced redundant completion - k(EitherUnit) - - // we *might* have negated a notification by succeeding here - // unnecessary wake-ups are mostly harmless (only slight fairness loss) - notifyOne() - - // don't bother with a finalizer since we're already complete - None - } catch { - case FailureSignal => - // println(s"failed take size = ${buffer.size()}") - // our retry failed, we're registered as a listener, so suspend - Some(F.delay(clear())) + val take: F[A] = F uncancelable { poll => + F defer { + try { + // attempt to take from the buffer. if it's empty, this will raise an exception + F.pure(buffer.take()) + } catch { + case FailureSignal => + // buffer was empty + // capture the fact that our retry succeeded and the value we were able to take + var received = false + var result: A = null.asInstanceOf[A] + + // a latch to block until some offerer wakes us up + val wait = F.asyncCheckAttempt[Unit] { k => + F delay { + // register ourselves as a listener for offers + val clear = takers.put(k) + + try { + // now that we're registered, retry the take + result = buffer.take() + + // it worked! clear out our listener + clear() + // we got a result, so received should be true now + received = true + + // we *might* have negated a notification by succeeding here + // unnecessary wake-ups are mostly harmless (only slight fairness loss) + notifyOne() + + // don't bother with a finalizer since we're already complete + EitherUnit + } catch { + case FailureSignal => + // println(s"failed take size = ${buffer.size()}") + // our retry failed, we're registered as a listener, so suspend + Left(Some(F.delay(clear()))) + } } } - } - // suspend until an offerer wakes us or our retry succeeds, then return a result - wait *> F.defer(if (received) F.pure(result) else take) + val notifyAnyway = F delay { + // we might have been awakened and canceled simultaneously + // try waking up another taker just in case + notifyOne() + } + + // suspend until an offerer wakes us or our retry succeeds, then return a result + (poll(wait) *> F.defer(if (received) F.pure(result) else poll(take))) + .onCancel(notifyAnyway) + } } } diff --git a/std/shared/src/main/scala/cats/effect/std/Random.scala b/std/shared/src/main/scala/cats/effect/std/Random.scala index 8be2e00a06..3268db340b 100644 --- a/std/shared/src/main/scala/cats/effect/std/Random.scala +++ b/std/shared/src/main/scala/cats/effect/std/Random.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/SecureRandom.scala b/std/shared/src/main/scala/cats/effect/std/SecureRandom.scala index 60aa27d303..709370dfdc 100644 --- a/std/shared/src/main/scala/cats/effect/std/SecureRandom.scala +++ b/std/shared/src/main/scala/cats/effect/std/SecureRandom.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Semaphore.scala b/std/shared/src/main/scala/cats/effect/std/Semaphore.scala index 4a8ed2b590..4b6e7d66c4 100644 --- a/std/shared/src/main/scala/cats/effect/std/Semaphore.scala +++ b/std/shared/src/main/scala/cats/effect/std/Semaphore.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/Supervisor.scala b/std/shared/src/main/scala/cats/effect/std/Supervisor.scala index 91423263a4..2feb3ed110 100644 --- a/std/shared/src/main/scala/cats/effect/std/Supervisor.scala +++ b/std/shared/src/main/scala/cats/effect/std/Supervisor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,17 +26,17 @@ import java.util.concurrent.ConcurrentHashMap /** * A fiber-based supervisor that monitors the lifecycle of all fibers that are started via its - * interface. The supervisor is managed by a singular fiber to which the lifecycles of all - * spawned fibers are bound. + * interface. The lifecycles of all these spawned fibers are bound to the lifecycle of the + * [[Supervisor]] itself. * * Whereas [[cats.effect.kernel.GenSpawn.background]] links the lifecycle of the spawned fiber * to the calling fiber, starting a fiber via a [[Supervisor]] links the lifecycle of the * spawned fiber to the supervisor fiber. This is useful when the scope of some fiber must * survive the spawner, but should still be confined within some "larger" scope. * - * The fibers started via the supervisor are guaranteed to be terminated when the supervisor - * fiber is terminated. When a supervisor fiber is canceled, all active and queued fibers will - * be safely finalized before finalization of the supervisor is complete. + * The fibers started via the supervisor are guaranteed to be terminated when the supervisor is + * terminated. When a supervisor is finalized, all active and queued fibers will be safely + * finalized before finalization of the supervisor is complete. * * The following diagrams illustrate the lifecycle of a fiber spawned via * [[cats.effect.kernel.GenSpawn.start]], [[cats.effect.kernel.GenSpawn.background]], and @@ -95,6 +95,9 @@ trait Supervisor[F[_]] { /** * Starts the supplied effect `fa` on the supervisor. * + * Trying to start an effect with this method on an already finalized supervisor results in an + * error (inside `F`). + * * @return * a [[cats.effect.kernel.Fiber]] that represents a handle to the started fiber. */ @@ -138,29 +141,33 @@ object Supervisor { def apply[F[_]: Concurrent]: Resource[F, Supervisor[F]] = apply[F](false) - private trait State[F[_]] { + private sealed abstract class State[F[_]] { + def remove(token: Unique.Token): F[Unit] - def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Unit] - // run all the finalizers + + /** + * Must return `false` (and might not insert) if `Supervisor` is already closed + */ + def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Boolean] + + // these are allowed to destroy the state, since they're only called during closing: val joinAll: F[Unit] val cancelAll: F[Unit] } private def supervisor[F[_]]( - mkState: F[State[F]], + mkState: Ref[F, Boolean] => F[State[F]], // receives the main shutdown flag await: Boolean, - checkRestart: Option[Outcome[F, Throwable, _] => Boolean])( + checkRestart: Option[Outcome[F, Throwable, _] => Boolean])( // `None` never restarts implicit F: Concurrent[F]): Resource[F, Supervisor[F]] = { - // It would have preferable to use Scope here but explicit cancelation is - // intertwined with resource management + for { doneR <- Resource.eval(F.ref(false)) - state <- Resource.makeCase(mkState) { - case (st, Resource.ExitCase.Succeeded) if await => doneR.set(true) >> st.joinAll + state <- Resource.makeCase(mkState(doneR)) { + case (st, Resource.ExitCase.Succeeded) if await => + doneR.set(true) *> st.joinAll case (st, _) => - doneR.set(true) >> { /*println("canceling all!");*/ - st.cancelAll - } + doneR.set(true) *> st.cancelAll } } yield new Supervisor[F] { @@ -170,53 +177,100 @@ object Supervisor { case Some(restart) => { (fa, fin) => F.deferred[Outcome[F, Throwable, A]] flatMap { resultR => F.ref(false) flatMap { canceledR => - F.deferred[Ref[F, Fiber[F, Throwable, A]]] flatMap { currentR => - lazy val action: F[Unit] = F uncancelable { _ => - val started = F start { - fa guaranteeCase { oc => - canceledR.get flatMap { canceled => - doneR.get flatMap { done => - if (!canceled && !done && restart(oc)) - action.void - else - fin.guarantee(resultR.complete(oc).void) + F.deferred[Fiber[F, Throwable, A]].flatMap { firstCurrent => + // `currentR` holds (a `Deferred` to) the current + // incarnation of the fiber executing `fa`: + F.ref(firstCurrent).flatMap { currentR => + def action(current: Deferred[F, Fiber[F, Throwable, A]]): F[Unit] = { + F uncancelable { _ => + val started = F start { + fa guaranteeCase { oc => + F.deferred[Fiber[F, Throwable, A]].flatMap { newCurrent => + // we're replacing the `Deferred` holding + // the current fiber with a new one before + // the current fiber finishes, and even + // before we check for the cancel signal; + // this guarantees, that the fiber reachable + // through `currentR` is the last one (or + // null, see below): + currentR.set(newCurrent) *> { + canceledR.get flatMap { canceled => + doneR.get flatMap { done => + if (!canceled && !done && restart(oc)) { + action(newCurrent) + } else { + // we must complete `newCurrent`, + // because `cancel` below may wait + // for it; we signal that it is not + // restarted with `null`: + newCurrent.complete(null) *> fin.guarantee( + resultR.complete(oc).void) + } + } + } + } + } } } - } - } - started flatMap { f => - lazy val loop: F[Unit] = currentR.tryGet flatMap { - case Some(inner) => - inner.set(f) - - case None => - F.ref(f) - .flatMap(inner => currentR.complete(inner).ifM(F.unit, loop)) + started flatMap { f => current.complete(f).void } } - - loop } - } - - action map { _ => - new Fiber[F, Throwable, A] { - private[this] val delegateF = currentR.get.flatMap(_.get) - - val cancel: F[Unit] = F uncancelable { _ => - canceledR.set(true) >> delegateF flatMap { fiber => - fiber.cancel >> fiber.join flatMap { - case Outcome.Canceled() => - resultR.complete(Outcome.Canceled()).void - case _ => - resultR.tryGet.map(_.isDefined).ifM(F.unit, cancel) + action(firstCurrent).as( + new Fiber[F, Throwable, A] { + + private[this] val delegateF = currentR.get.flatMap(_.get) + + val cancel: F[Unit] = F uncancelable { _ => + // after setting `canceledR`, at + // most one restart happens, and + // the fiber we get through `delegateF` + // is the final one: + canceledR.set(true) *> delegateF flatMap { + case null => + // ok, task wasn't restarted, but we + // wait for the result to be completed + // (and the finalizer to run): + resultR.get.void + case fiber => + fiber.cancel *> fiber.join flatMap { + case Outcome.Canceled() => + // cancel successful (or self-canceled), + // but we don't know if the `guaranteeCase` + // above ran so we need to double check: + delegateF.flatMap { + case null => + // ok, the `guaranteeCase` + // certainly executed/ing: + resultR.get.void + case fiber2 => + // we cancelled the fiber before it did + // anything, so the finalizer didn't run, + // we need to do it now: + val cleanup = fin.guarantee( + resultR.complete(Outcome.Canceled()).void + ) + if (fiber2 eq fiber) { + cleanup + } else { + // this should never happen + cleanup *> F.raiseError(new AssertionError( + "unexpected fiber (this is a bug in Supervisor)")) + } + } + case _ => + // finished in error/success, + // the outcome will certainly + // be completed: + resultR.get.void + } } } - } - val join = resultR.get - } + def join = resultR.get + } + ) } } } @@ -228,11 +282,36 @@ object Supervisor { for { done <- F.ref(false) + insertResult <- F.deferred[Boolean] token <- F.unique cleanup = state.remove(token) - fiber <- monitor(fa, done.set(true) >> cleanup) - _ <- state.add(token, fiber) + fiber <- monitor( + // if the supervisor have been (or is now) + // shutting down, inserting into state will + // fail; so we need to wait for the positive result + // of inserting, before actually doing the task: + insertResult + .get + .ifM( + fa, + F.canceled *> F.raiseError[A](new AssertionError( + "supervised fiber couldn't cancel (this is a bug in Supervisor)")) + ), + done.set(true) *> cleanup + ) + insertOk <- state.add(token, fiber) + _ <- insertResult.complete(insertOk) + // `cleanup` could run BEFORE the `state.add` + // (if `fa` is very fast), in which case it doesn't + // remove the fiber from the state, so we re-check: _ <- done.get.ifM(cleanup, F.unit) + _ <- { + if (!insertOk) { + F.raiseError(new IllegalStateException("supervisor already shutdown")) + } else { + F.unit + } + } } yield fiber } } @@ -244,44 +323,64 @@ object Supervisor { implicit F: Concurrent[F]): Resource[F, Supervisor[F]] = { val mkState = F.ref[Map[Unique.Token, Fiber[F, Throwable, _]]](Map.empty).map { stateRef => new State[F] { - def remove(token: Unique.Token): F[Unit] = stateRef.update(_ - token) - def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Unit] = - stateRef.update(_ + (token -> fiber)) - private[this] val allFibers: F[List[Fiber[F, Throwable, _]]] = - stateRef.get.map(_.values.toList) + def remove(token: Unique.Token): F[Unit] = stateRef.update { + case null => null + case map => map - token + } + + def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Boolean] = + stateRef.modify { + case null => (null, false) + case map => (map.updated(token, fiber), true) + } + + private[this] val allFibers: F[List[Fiber[F, Throwable, _]]] = { + // we're closing, so we won't need the state any more, + // so we're using `null` as a sentinel to reject later + // insertions in `add`: + stateRef.getAndSet(null).map(_.values.toList) + } val joinAll: F[Unit] = allFibers.flatMap(_.traverse_(_.join.void)) + val cancelAll: F[Unit] = allFibers.flatMap(_.parUnorderedTraverse(_.cancel).void) } } - supervisor(mkState, await, checkRestart) + supervisor(_ => mkState, await, checkRestart) } private[effect] def applyForAsync[F[_]]( await: Boolean, checkRestart: Option[Outcome[F, Throwable, _] => Boolean])( implicit F: Async[F]): Resource[F, Supervisor[F]] = { - val mkState = F.delay { + def mkState(doneR: Ref[F, Boolean]) = F.delay { val state = new ConcurrentHashMap[Unique.Token, Fiber[F, Throwable, _]] new State[F] { def remove(token: Unique.Token): F[Unit] = F.delay(state.remove(token)).void - def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Unit] = - F.delay(state.put(token, fiber)).void + def add(token: Unique.Token, fiber: Fiber[F, Throwable, _]): F[Boolean] = { + // We might insert a fiber even when closed, but + // then we return `false`, so it will not actually + // execute its task, but will self-cancel. In this + // case we need not remove the (cancelled) fiber + // from the map, since the whole `Supervisor` is + // shutting down anyway. + F.delay(state.put(token, fiber)) *> doneR.get.map(!_) + } private[this] val allFibers: F[List[Fiber[F, Throwable, _]]] = F delay { - val fibersToCancel = ListBuffer.empty[Fiber[F, Throwable, _]] - fibersToCancel.sizeHint(state.size()) + val fibers = ListBuffer.empty[Fiber[F, Throwable, _]] + fibers.sizeHint(state.size()) val values = state.values().iterator() while (values.hasNext) { - fibersToCancel += values.next() + fibers += values.next() } - fibersToCancel.result() + fibers.result() } val joinAll: F[Unit] = allFibers.flatMap(_.traverse_(_.join.void)) diff --git a/std/shared/src/main/scala/cats/effect/std/UUIDGen.scala b/std/shared/src/main/scala/cats/effect/std/UUIDGen.scala index b49d4aa481..a453131269 100644 --- a/std/shared/src/main/scala/cats/effect/std/UUIDGen.scala +++ b/std/shared/src/main/scala/cats/effect/std/UUIDGen.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/UnsafeUnbounded.scala b/std/shared/src/main/scala/cats/effect/std/UnsafeUnbounded.scala index 623cf4daeb..40bef4e75c 100644 --- a/std/shared/src/main/scala/cats/effect/std/UnsafeUnbounded.scala +++ b/std/shared/src/main/scala/cats/effect/std/UnsafeUnbounded.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/internal/BankersQueue.scala b/std/shared/src/main/scala/cats/effect/std/internal/BankersQueue.scala index 06d66f83e6..80603b33d5 100644 --- a/std/shared/src/main/scala/cats/effect/std/internal/BankersQueue.scala +++ b/std/shared/src/main/scala/cats/effect/std/internal/BankersQueue.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/internal/BinomialHeap.scala b/std/shared/src/main/scala/cats/effect/std/internal/BinomialHeap.scala index ce61b7e41a..de439d9fca 100644 --- a/std/shared/src/main/scala/cats/effect/std/internal/BinomialHeap.scala +++ b/std/shared/src/main/scala/cats/effect/std/internal/BinomialHeap.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/syntax/AllSyntax.scala b/std/shared/src/main/scala/cats/effect/std/syntax/AllSyntax.scala index b247c840f7..cbeff8f12c 100644 --- a/std/shared/src/main/scala/cats/effect/std/syntax/AllSyntax.scala +++ b/std/shared/src/main/scala/cats/effect/std/syntax/AllSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/syntax/BackpressureSyntax.scala b/std/shared/src/main/scala/cats/effect/std/syntax/BackpressureSyntax.scala index 3ec350f104..dd2c2f77b6 100644 --- a/std/shared/src/main/scala/cats/effect/std/syntax/BackpressureSyntax.scala +++ b/std/shared/src/main/scala/cats/effect/std/syntax/BackpressureSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/syntax/SupervisorSyntax.scala b/std/shared/src/main/scala/cats/effect/std/syntax/SupervisorSyntax.scala index 903030404a..0f7ecf611d 100644 --- a/std/shared/src/main/scala/cats/effect/std/syntax/SupervisorSyntax.scala +++ b/std/shared/src/main/scala/cats/effect/std/syntax/SupervisorSyntax.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/main/scala/cats/effect/std/syntax/package.scala b/std/shared/src/main/scala/cats/effect/std/syntax/package.scala index 0a3cebea4e..9f8775d6bd 100644 --- a/std/shared/src/main/scala/cats/effect/std/syntax/package.scala +++ b/std/shared/src/main/scala/cats/effect/std/syntax/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/std/shared/src/test/scala/cats/effect/std/SyntaxSpec.scala b/std/shared/src/test/scala/cats/effect/std/SyntaxSpec.scala index a9f2a9661d..81d297c5c0 100644 --- a/std/shared/src/test/scala/cats/effect/std/SyntaxSpec.scala +++ b/std/shared/src/test/scala/cats/effect/std/SyntaxSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/testkit/shared/src/main/scala/cats/effect/testkit/TestControl.scala b/testkit/shared/src/main/scala/cats/effect/testkit/TestControl.scala index 635b8aefef..61b779a841 100644 --- a/testkit/shared/src/main/scala/cats/effect/testkit/TestControl.scala +++ b/testkit/shared/src/main/scala/cats/effect/testkit/TestControl.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/testkit/shared/src/main/scala/cats/effect/testkit/TestException.scala b/testkit/shared/src/main/scala/cats/effect/testkit/TestException.scala index aa03863f58..54f2012577 100644 --- a/testkit/shared/src/main/scala/cats/effect/testkit/TestException.scala +++ b/testkit/shared/src/main/scala/cats/effect/testkit/TestException.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/testkit/shared/src/main/scala/cats/effect/testkit/TestInstances.scala b/testkit/shared/src/main/scala/cats/effect/testkit/TestInstances.scala index 1f0d1477fe..2b2f138299 100644 --- a/testkit/shared/src/main/scala/cats/effect/testkit/TestInstances.scala +++ b/testkit/shared/src/main/scala/cats/effect/testkit/TestInstances.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/testkit/shared/src/main/scala/cats/effect/testkit/package.scala b/testkit/shared/src/main/scala/cats/effect/testkit/package.scala index 66949fc188..457360dd24 100644 --- a/testkit/shared/src/main/scala/cats/effect/testkit/package.scala +++ b/testkit/shared/src/main/scala/cats/effect/testkit/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js-native/src/test/scala/cats/effect/ContSpecBasePlatform.scala b/tests/js-native/src/test/scala/cats/effect/ContSpecBasePlatform.scala index 02f72e48c9..123e1cacaa 100644 --- a/tests/js-native/src/test/scala/cats/effect/ContSpecBasePlatform.scala +++ b/tests/js-native/src/test/scala/cats/effect/ContSpecBasePlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/main/scala/cats/effect/DetectPlatform.scala b/tests/js/src/main/scala/cats/effect/DetectPlatform.scala index fcab3c323a..540fec2572 100644 --- a/tests/js/src/main/scala/cats/effect/DetectPlatform.scala +++ b/tests/js/src/main/scala/cats/effect/DetectPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/main/scala/catseffect/examplesplatform.scala b/tests/js/src/main/scala/catseffect/examplesplatform.scala index bb4fcb34b3..53ef8c7ac2 100644 --- a/tests/js/src/main/scala/catseffect/examplesplatform.scala +++ b/tests/js/src/main/scala/catseffect/examplesplatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/IOPlatformSpecification.scala b/tests/js/src/test/scala/cats/effect/IOPlatformSpecification.scala index b264607c74..81532a55fb 100644 --- a/tests/js/src/test/scala/cats/effect/IOPlatformSpecification.scala +++ b/tests/js/src/test/scala/cats/effect/IOPlatformSpecification.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/RunnersPlatform.scala b/tests/js/src/test/scala/cats/effect/RunnersPlatform.scala index a2eec251fe..8661376813 100644 --- a/tests/js/src/test/scala/cats/effect/RunnersPlatform.scala +++ b/tests/js/src/test/scala/cats/effect/RunnersPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala b/tests/js/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala index adf5ec18c8..7664df815a 100644 --- a/tests/js/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala +++ b/tests/js/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/exports.scala b/tests/js/src/test/scala/cats/effect/exports.scala index ff064ac9f9..4eb65608fb 100644 --- a/tests/js/src/test/scala/cats/effect/exports.scala +++ b/tests/js/src/test/scala/cats/effect/exports.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/std/ConsoleJSSpec.scala b/tests/js/src/test/scala/cats/effect/std/ConsoleJSSpec.scala index d645c1f5ea..af588c26f8 100644 --- a/tests/js/src/test/scala/cats/effect/std/ConsoleJSSpec.scala +++ b/tests/js/src/test/scala/cats/effect/std/ConsoleJSSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/unsafe/BatchingMacrotaskExecutorSpec.scala b/tests/js/src/test/scala/cats/effect/unsafe/BatchingMacrotaskExecutorSpec.scala index c6745b8c6a..607e60ee6e 100644 --- a/tests/js/src/test/scala/cats/effect/unsafe/BatchingMacrotaskExecutorSpec.scala +++ b/tests/js/src/test/scala/cats/effect/unsafe/BatchingMacrotaskExecutorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/unsafe/JSArrayQueueSpec.scala b/tests/js/src/test/scala/cats/effect/unsafe/JSArrayQueueSpec.scala index 432e82bdf8..5975c29f3f 100644 --- a/tests/js/src/test/scala/cats/effect/unsafe/JSArrayQueueSpec.scala +++ b/tests/js/src/test/scala/cats/effect/unsafe/JSArrayQueueSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala b/tests/js/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala index f5e4ee5b74..afab02ae90 100644 --- a/tests/js/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala +++ b/tests/js/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/js/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala b/tests/js/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala index d3ef3c7675..abed3e1600 100644 --- a/tests/js/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala +++ b/tests/js/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm-native/src/main/scala/catseffect/examplesjvmnative.scala b/tests/jvm-native/src/main/scala/catseffect/examplesjvmnative.scala index 6e5b4a5d49..878e515ea3 100644 --- a/tests/jvm-native/src/main/scala/catseffect/examplesjvmnative.scala +++ b/tests/jvm-native/src/main/scala/catseffect/examplesjvmnative.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm-native/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala b/tests/jvm-native/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala index 084e2382c7..13be3abad0 100644 --- a/tests/jvm-native/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala +++ b/tests/jvm-native/src/test/scala/cats/effect/SyncIOPlatformSpecification.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/main/scala/catseffect/examplesplatform.scala b/tests/jvm/src/main/scala/catseffect/examplesplatform.scala index 9c4fb81f43..7fa6f16638 100644 --- a/tests/jvm/src/main/scala/catseffect/examplesplatform.scala +++ b/tests/jvm/src/main/scala/catseffect/examplesplatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/ContSpecBasePlatform.scala b/tests/jvm/src/test/scala/cats/effect/ContSpecBasePlatform.scala index a9067b60e1..e84c4f7644 100644 --- a/tests/jvm/src/test/scala/cats/effect/ContSpecBasePlatform.scala +++ b/tests/jvm/src/test/scala/cats/effect/ContSpecBasePlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/DetectPlatform.scala b/tests/jvm/src/test/scala/cats/effect/DetectPlatform.scala index 0cd7da54fd..fc8b5d5d26 100644 --- a/tests/jvm/src/test/scala/cats/effect/DetectPlatform.scala +++ b/tests/jvm/src/test/scala/cats/effect/DetectPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/IOPlatformSpecification.scala b/tests/jvm/src/test/scala/cats/effect/IOPlatformSpecification.scala index de795278eb..63ad3e78ca 100644 --- a/tests/jvm/src/test/scala/cats/effect/IOPlatformSpecification.scala +++ b/tests/jvm/src/test/scala/cats/effect/IOPlatformSpecification.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/ParasiticECSpec.scala b/tests/jvm/src/test/scala/cats/effect/ParasiticECSpec.scala index deb9e3fdd0..20ea86d867 100644 --- a/tests/jvm/src/test/scala/cats/effect/ParasiticECSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/ParasiticECSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/ResourceJVMSpec.scala b/tests/jvm/src/test/scala/cats/effect/ResourceJVMSpec.scala index 7d791b7421..848039bb03 100644 --- a/tests/jvm/src/test/scala/cats/effect/ResourceJVMSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/ResourceJVMSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/RunnersPlatform.scala b/tests/jvm/src/test/scala/cats/effect/RunnersPlatform.scala index a325c4e310..19bb62b57d 100644 --- a/tests/jvm/src/test/scala/cats/effect/RunnersPlatform.scala +++ b/tests/jvm/src/test/scala/cats/effect/RunnersPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala b/tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala index 4eab39d37c..30f9dcc387 100644 --- a/tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/std/ConsoleJVMSpec.scala b/tests/jvm/src/test/scala/cats/effect/std/ConsoleJVMSpec.scala index 898e51d33c..dcd1fd0d3d 100644 --- a/tests/jvm/src/test/scala/cats/effect/std/ConsoleJVMSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/std/ConsoleJVMSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/std/DeferredJVMSpec.scala b/tests/jvm/src/test/scala/cats/effect/std/DeferredJVMSpec.scala index 6d045b6822..56c427b621 100644 --- a/tests/jvm/src/test/scala/cats/effect/std/DeferredJVMSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/std/DeferredJVMSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala b/tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala index f423dffb71..f0df165da8 100644 --- a/tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/std/MapRefJVMSpec.scala b/tests/jvm/src/test/scala/cats/effect/std/MapRefJVMSpec.scala index cdfab459d2..45d4e87eae 100644 --- a/tests/jvm/src/test/scala/cats/effect/std/MapRefJVMSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/std/MapRefJVMSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/BlockingStressSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/BlockingStressSpec.scala index 95dbc9880d..a89d412d82 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/BlockingStressSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/BlockingStressSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/DrainBatchSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/DrainBatchSpec.scala index d8d07bc057..4d6d35f408 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/DrainBatchSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/DrainBatchSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/FiberMonitorSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/FiberMonitorSpec.scala index 2ca227ec19..9923cbdc22 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/FiberMonitorSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/FiberMonitorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/HelperThreadParkSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/HelperThreadParkSpec.scala index 303fe7689e..4c08026578 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/HelperThreadParkSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/HelperThreadParkSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/SleepersSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/SleepersSpec.scala index f5690525fc..de3e4c5a9e 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/SleepersSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/SleepersSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala index c1b5cdb375..bfffc7ec25 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/StripedHashtableSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/jvm/src/test/scala/cats/effect/unsafe/TimerHeapSpec.scala b/tests/jvm/src/test/scala/cats/effect/unsafe/TimerHeapSpec.scala index 711de0a040..798e75c073 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/TimerHeapSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/TimerHeapSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 74100f8077..21845da279 100644 --- a/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala +++ b/tests/jvm/src/test/scala/cats/effect/unsafe/WorkerThreadNameSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/native/src/main/scala/catseffect/examplesplatform.scala b/tests/native/src/main/scala/catseffect/examplesplatform.scala index 937aca6685..2e33e7753c 100644 --- a/tests/native/src/main/scala/catseffect/examplesplatform.scala +++ b/tests/native/src/main/scala/catseffect/examplesplatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/native/src/test/scala/cats/effect/DetectPlatform.scala b/tests/native/src/test/scala/cats/effect/DetectPlatform.scala index 058f786177..58a33bbbdd 100644 --- a/tests/native/src/test/scala/cats/effect/DetectPlatform.scala +++ b/tests/native/src/test/scala/cats/effect/DetectPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/native/src/test/scala/cats/effect/IOPlatformSpecification.scala b/tests/native/src/test/scala/cats/effect/IOPlatformSpecification.scala index 60902a0b23..05dfc8973d 100644 --- a/tests/native/src/test/scala/cats/effect/IOPlatformSpecification.scala +++ b/tests/native/src/test/scala/cats/effect/IOPlatformSpecification.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/native/src/test/scala/cats/effect/RunnersPlatform.scala b/tests/native/src/test/scala/cats/effect/RunnersPlatform.scala index 0aaf1865ef..de5f1c4033 100644 --- a/tests/native/src/test/scala/cats/effect/RunnersPlatform.scala +++ b/tests/native/src/test/scala/cats/effect/RunnersPlatform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/native/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala b/tests/native/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala index 2d280257cc..1a266c9ed1 100644 --- a/tests/native/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala +++ b/tests/native/src/test/scala/cats/effect/unsafe/SchedulerSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/main/scala/catseffect/RawApp.scala b/tests/shared/src/main/scala/catseffect/RawApp.scala index f813bceca1..1105d443ba 100644 --- a/tests/shared/src/main/scala/catseffect/RawApp.scala +++ b/tests/shared/src/main/scala/catseffect/RawApp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/main/scala/catseffect/examples.scala b/tests/shared/src/main/scala/catseffect/examples.scala index 682302a047..77967346c3 100644 --- a/tests/shared/src/main/scala/catseffect/examples.scala +++ b/tests/shared/src/main/scala/catseffect/examples.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala-2.13+/not/cats/effect/IOParImplicitSpec.scala b/tests/shared/src/test/scala-2.13+/not/cats/effect/IOParImplicitSpec.scala index 15f4c49946..48d3b299a5 100644 --- a/tests/shared/src/test/scala-2.13+/not/cats/effect/IOParImplicitSpec.scala +++ b/tests/shared/src/test/scala-2.13+/not/cats/effect/IOParImplicitSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/BaseSpec.scala b/tests/shared/src/test/scala/cats/effect/BaseSpec.scala index 30462134b3..9863b51082 100644 --- a/tests/shared/src/test/scala/cats/effect/BaseSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/BaseSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/CallbackStackSpec.scala b/tests/shared/src/test/scala/cats/effect/CallbackStackSpec.scala index 151d5bf3d0..8f0dd5899d 100644 --- a/tests/shared/src/test/scala/cats/effect/CallbackStackSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/CallbackStackSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package cats.effect -import cats.syntax.all._ - class CallbackStackSpec extends BaseSpec with DetectPlatform { "CallbackStack" should { @@ -52,14 +50,6 @@ class CallbackStackSpec extends BaseSpec with DetectPlatform { } } - "pack runs concurrently with clear" in real { - IO { - val stack = CallbackStack.of[Unit](null) - val handle = stack.push(_ => ()) - stack.clearHandle(handle) - stack - }.flatMap(stack => IO(stack.pack(1)).both(IO(stack.clear()))).parReplicateA_(1000).as(ok) - } } } diff --git a/tests/shared/src/test/scala/cats/effect/ContSpec.scala b/tests/shared/src/test/scala/cats/effect/ContSpec.scala index 261f24639b..df2012fcc4 100644 --- a/tests/shared/src/test/scala/cats/effect/ContSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/ContSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/EitherTIOSpec.scala b/tests/shared/src/test/scala/cats/effect/EitherTIOSpec.scala index 14dcbf5b1f..44233acc0d 100644 --- a/tests/shared/src/test/scala/cats/effect/EitherTIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/EitherTIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/ExitCodeSpec.scala b/tests/shared/src/test/scala/cats/effect/ExitCodeSpec.scala index b43a190da3..27d2d47745 100644 --- a/tests/shared/src/test/scala/cats/effect/ExitCodeSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/ExitCodeSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/IOFiberSpec.scala b/tests/shared/src/test/scala/cats/effect/IOFiberSpec.scala index 582eaf1bf4..429115d279 100644 --- a/tests/shared/src/test/scala/cats/effect/IOFiberSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOFiberSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/IOLocalSpec.scala b/tests/shared/src/test/scala/cats/effect/IOLocalSpec.scala index 3bea60a5b9..c187f3aac1 100644 --- a/tests/shared/src/test/scala/cats/effect/IOLocalSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOLocalSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/IOParSpec.scala b/tests/shared/src/test/scala/cats/effect/IOParSpec.scala index a6056aac58..71065c1570 100644 --- a/tests/shared/src/test/scala/cats/effect/IOParSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOParSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/IOPropSpec.scala b/tests/shared/src/test/scala/cats/effect/IOPropSpec.scala index 3d3c5181b6..2784c3f497 100644 --- a/tests/shared/src/test/scala/cats/effect/IOPropSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOPropSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/IOSpec.scala b/tests/shared/src/test/scala/cats/effect/IOSpec.scala index 0c913adf81..a4e2359f6b 100644 --- a/tests/shared/src/test/scala/cats/effect/IOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -635,6 +635,17 @@ class IOSpec extends BaseSpec with Discipline with IOPlatformSpecification { outerR mustEqual 1 innerR mustEqual 2 } + + "be uncancelable if None finalizer" in ticked { implicit ticker => + val t = IO.asyncCheckAttempt[Int] { _ => IO.pure(Left(None)) } + val test = for { + fib <- t.start + _ <- IO(ticker.ctx.tick()) + _ <- fib.cancel + } yield () + + test must nonTerminate + } } "async" should { diff --git a/tests/shared/src/test/scala/cats/effect/IorTIOSpec.scala b/tests/shared/src/test/scala/cats/effect/IorTIOSpec.scala index 572d145fd0..264f68d045 100644 --- a/tests/shared/src/test/scala/cats/effect/IorTIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/IorTIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/KleisliIOSpec.scala b/tests/shared/src/test/scala/cats/effect/KleisliIOSpec.scala index 91b6068abf..4b2e689b42 100644 --- a/tests/shared/src/test/scala/cats/effect/KleisliIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/KleisliIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/MemoizeSpec.scala b/tests/shared/src/test/scala/cats/effect/MemoizeSpec.scala index 15b386d2b7..e37aa4e757 100644 --- a/tests/shared/src/test/scala/cats/effect/MemoizeSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/MemoizeSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/OptionTIOSpec.scala b/tests/shared/src/test/scala/cats/effect/OptionTIOSpec.scala index 1781427bba..9a2e3e9824 100644 --- a/tests/shared/src/test/scala/cats/effect/OptionTIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/OptionTIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/ResourceSpec.scala b/tests/shared/src/test/scala/cats/effect/ResourceSpec.scala index 694cbc7198..d48272f98a 100644 --- a/tests/shared/src/test/scala/cats/effect/ResourceSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/ResourceSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/Runners.scala b/tests/shared/src/test/scala/cats/effect/Runners.scala index e8fbfc2423..68213d0720 100644 --- a/tests/shared/src/test/scala/cats/effect/Runners.scala +++ b/tests/shared/src/test/scala/cats/effect/Runners.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,10 @@ trait Runners extends SpecificationLike with TestInstances with RunnersPlatform Execution.result(test(Ticker(TestContext()))) def real[A: AsResult](test: => IO[A]): Execution = - Execution.withEnvAsync(_ => timeout(test.unsafeToFuture()(runtime()), executionTimeout)) + Execution.withEnvAsync { _ => + val (fut, cancel) = test.unsafeToFutureCancelable()(runtime()) + timeout(fut, cancel, executionTimeout) + } /* * Hacky implementation of effectful property testing @@ -53,7 +56,8 @@ trait Runners extends SpecificationLike with TestInstances with RunnersPlatform def realWithRuntime[A: AsResult](test: IORuntime => IO[A]): Execution = Execution.withEnvAsync { _ => val rt = runtime() - timeout(test(rt).unsafeToFuture()(rt), executionTimeout) + val (fut, cancel) = test(rt).unsafeToFutureCancelable()(rt) + timeout(fut, cancel, executionTimeout) } def completeAs[A: Eq: Show](expected: A)(implicit ticker: Ticker): Matcher[IO[A]] = @@ -100,17 +104,29 @@ trait Runners extends SpecificationLike with TestInstances with RunnersPlatform def mustEqual(a: A) = fa.flatMap { res => IO(res must beEqualTo(a)) } } - private def timeout[A](f: Future[A], duration: FiniteDuration): Future[A] = { + private def timeout[A]( + f: Future[A], + cancel: () => Future[Unit], + duration: FiniteDuration): Future[A] = { val p = Promise[A]() val r = runtime() implicit val ec = r.compute - val cancel = - r.scheduler.sleep(duration, { () => p.tryFailure(new TestTimeoutException); () }) + val cancelTimer = + r.scheduler + .sleep( + duration, + { () => + if (p.tryFailure(new TestTimeoutException)) { + cancel() + () + } + }) f.onComplete { result => - p.tryComplete(result) - cancel.run() + if (p.tryComplete(result)) { + cancelTimer.run() + } } p.future diff --git a/tests/shared/src/test/scala/cats/effect/StateTIOSpec.scala b/tests/shared/src/test/scala/cats/effect/StateTIOSpec.scala index 39001e990b..c276b15c70 100644 --- a/tests/shared/src/test/scala/cats/effect/StateTIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/StateTIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/SyncIOSpec.scala b/tests/shared/src/test/scala/cats/effect/SyncIOSpec.scala index 14223c67dc..6daa362392 100644 --- a/tests/shared/src/test/scala/cats/effect/SyncIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/SyncIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/ThunkSpec.scala b/tests/shared/src/test/scala/cats/effect/ThunkSpec.scala index f51f7b1e98..695790c59b 100644 --- a/tests/shared/src/test/scala/cats/effect/ThunkSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/ThunkSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/WriterTIOSpec.scala b/tests/shared/src/test/scala/cats/effect/WriterTIOSpec.scala index 17dbef134d..b6fc977d6e 100644 --- a/tests/shared/src/test/scala/cats/effect/WriterTIOSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/WriterTIOSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/AsyncSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/AsyncSpec.scala index 84fb985e9d..d502d4f1b2 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/AsyncSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/AsyncSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/DeferredSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/DeferredSpec.scala index 2d5e969588..fc9e73af35 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/DeferredSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/DeferredSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/DerivationRefinementSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/DerivationRefinementSpec.scala index 3b434a22f1..5d7b7376f4 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/DerivationRefinementSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/DerivationRefinementSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/LensRefSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/LensRefSpec.scala index 193626b629..bb3bba6cdc 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/LensRefSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/LensRefSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/MiniSemaphoreSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/MiniSemaphoreSpec.scala index e9c33469dd..cd67b0a8dd 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/MiniSemaphoreSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/MiniSemaphoreSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/ParallelFSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/ParallelFSpec.scala index 3227913829..6118a62ee7 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/ParallelFSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/ParallelFSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/kernel/RefSpec.scala b/tests/shared/src/test/scala/cats/effect/kernel/RefSpec.scala index 65fefd197d..1ef569f0f1 100644 --- a/tests/shared/src/test/scala/cats/effect/kernel/RefSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/kernel/RefSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/AtomicCellSpec.scala b/tests/shared/src/test/scala/cats/effect/std/AtomicCellSpec.scala index 16cdd02f9f..9f3a6a73f0 100644 --- a/tests/shared/src/test/scala/cats/effect/std/AtomicCellSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/AtomicCellSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/BackpressureSpec.scala b/tests/shared/src/test/scala/cats/effect/std/BackpressureSpec.scala index a6af51f3bc..ad8148b1cf 100644 --- a/tests/shared/src/test/scala/cats/effect/std/BackpressureSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/BackpressureSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/ConsoleSpec.scala b/tests/shared/src/test/scala/cats/effect/std/ConsoleSpec.scala index c18a1e3674..6b6f48f7a0 100644 --- a/tests/shared/src/test/scala/cats/effect/std/ConsoleSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/ConsoleSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/CountDownLatchSpec.scala b/tests/shared/src/test/scala/cats/effect/std/CountDownLatchSpec.scala index 018147f8a8..cacac0dd4d 100644 --- a/tests/shared/src/test/scala/cats/effect/std/CountDownLatchSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/CountDownLatchSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/CyclicBarrierSpec.scala b/tests/shared/src/test/scala/cats/effect/std/CyclicBarrierSpec.scala index 6bb97f1a08..4877ac5aa9 100644 --- a/tests/shared/src/test/scala/cats/effect/std/CyclicBarrierSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/CyclicBarrierSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/DequeueSpec.scala b/tests/shared/src/test/scala/cats/effect/std/DequeueSpec.scala index c60271d5e4..b936db25c8 100644 --- a/tests/shared/src/test/scala/cats/effect/std/DequeueSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/DequeueSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala b/tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala index 57b2733551..22bd124e18 100644 --- a/tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/DispatcherSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,15 +24,17 @@ import cats.syntax.all._ import scala.concurrent.{ExecutionContext, Promise} import scala.concurrent.duration._ +import java.util.concurrent.atomic.AtomicInteger + class DispatcherSpec extends BaseSpec with DetectPlatform { override def executionTimeout = 30.seconds - "sequential dispatcher" should { + "sequential dispatcher (cancelable = false)" should { "await = true" >> { val D = Dispatcher.sequential[IO](await = true) - sequential(D) + sequential(D, false) awaitTermination(D) @@ -41,12 +43,97 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { .replicateA(if (isJS || isNative) 1 else 10000) .as(true) } + + "await work queue drain on shutdown" in real { + val count = 1000 + + IO.ref(0) flatMap { resultsR => + val increments = D use { runner => + IO { + 0.until(count).foreach(_ => runner.unsafeRunAndForget(resultsR.update(_ + 1))) + } + } + + increments *> resultsR.get.flatMap(r => IO(r mustEqual count)) + } + } + + "terminating worker preserves task order" in real { + val count = 10 + + IO.ref(Vector[Int]()) flatMap { resultsR => + val appends = D use { runner => + IO { + 0.until(count).foreach(i => runner.unsafeRunAndForget(resultsR.update(_ :+ i))) + } + } + + appends *> resultsR.get.flatMap(r => IO(r mustEqual 0.until(count).toVector)) + } + } + + "correctly backpressure cancellation" in real { + D.use { dispatcher => + IO.ref(0).flatMap { ctr1 => + IO.ref(0).flatMap { ctr2 => + IO.fromFuture(IO { + val (_, cancel) = dispatcher.unsafeToFutureCancelable(IO.uncancelable { _ => + ctr1.update(_ + 1) *> IO.sleep(0.1.second) *> ctr2.update(_ + 1) + }) + val cancelFut = cancel() + cancelFut + }).flatMap { _ => + // if we're here, `cancel()` finished, so + // either the task didn't run at all (i.e., + // it was cancelled before starting), or + // it ran and already finished completely: + (ctr1.get, ctr2.get).flatMapN { (v1, v2) => IO(v1 mustEqual v2) } + } + } + } + }.replicateA_(if (isJVM) 10000 else 1) + .as(ok) + } } "await = false" >> { val D = Dispatcher.sequential[IO](await = false) - sequential(D) + sequential(D, false) + + "cancel all inner effects when canceled" in real { + var canceled = false + + val body = D use { runner => + IO(runner.unsafeRunAndForget(IO.never.onCancel(IO { canceled = true }))) *> IO.never + } + + val action = body.start.flatMap(f => IO.sleep(500.millis) *> f.cancel) + + TestControl.executeEmbed(action *> IO(canceled must beTrue)) + } + } + } + + "sequential dispatcher (cancelable = true)" should { + "await = true" >> { + val D = Dispatcher.sequentialCancelable[IO](await = true) + + sequential(D, true) + + awaitTermination(D) + + "not hang" in real { + D.use(dispatcher => IO(dispatcher.unsafeRunAndForget(IO.unit))) + .replicateA(if (isJS || isNative) 1 else 10000) + .as(true) + } + } + + "await = false" >> { + val D = Dispatcher.sequentialCancelable[IO](await = false) + + sequential(D, true) "cancel all inner effects when canceled" in real { var canceled = false @@ -62,9 +149,9 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } } - private def sequential(dispatcher: Resource[IO, Dispatcher[IO]]) = { + private def sequential(dispatcher: Resource[IO, Dispatcher[IO]], cancelable: Boolean) = { - common(dispatcher) + common(dispatcher, cancelable) "strictly sequentialize multiple IOs" in real { val length = 1000 @@ -86,22 +173,67 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } yield ok } - "ignore action cancelation" in real { - var canceled = false - - val rec = dispatcher flatMap { runner => - val run = IO { - runner - .unsafeToFutureCancelable(IO.sleep(500.millis).onCancel(IO { canceled = true })) - ._2 + "reject new tasks after release action is submitted as a task" in ticked { + implicit ticker => + val test = dispatcher.allocated.flatMap { + case (runner, release) => + IO(runner.unsafeRunAndForget(release)) *> + IO.sleep(100.millis) *> + IO(runner.unsafeRunAndForget(IO(ko)) must throwAn[IllegalStateException]) } - Resource eval { - run.flatMap(ct => IO.sleep(200.millis) >> IO.fromFuture(IO(ct()))) + test.void must completeAs(()) + } + + "invalidate cancelation action of task when complete" in real { + val test = dispatcher use { runner => + for { + latch1 <- IO.deferred[Unit] + latch2 <- IO.deferred[Unit] + latch3 <- IO.deferred[Unit] + + pair <- IO(runner.unsafeToFutureCancelable(IO.unit)) + (_, cancel) = pair + + _ <- IO( + runner.unsafeRunAndForget(latch1.complete(()) *> latch2.get *> latch3.complete(()))) + + _ <- latch1.get + _ <- IO.fromFuture(IO(cancel())) + _ <- latch2.complete(()) + + _ <- latch3.get // this will hang if the test is failing + } yield ok + } + + test.parReplicateA_(1000).as(ok) + } + + "invalidate cancelation action when racing with task" in real { + val test = dispatcher use { runner => + IO.ref(false) flatMap { resultR => + for { + latch1 <- IO.deferred[Unit] + latch2 <- IO.deferred[Unit] + + pair <- IO(runner.unsafeToFutureCancelable(latch1.get)) + (_, cancel) = pair + + _ <- latch1.complete(()) + // the particularly scary case is where the cancel action gets in queue before the next action + f <- IO(cancel()) + + // we're testing to make sure this task runs and isn't canceled + _ <- IO(runner.unsafeRunAndForget(resultR.set(true) *> latch2.complete(()))) + _ <- IO.fromFuture(IO.pure(f)) + _ <- latch2.get + + b <- resultR.get + } yield b } } - TestControl.executeEmbed(rec.use(_ => IO(canceled must beFalse))) + test.flatMap(b => IO(b must beTrue)).parReplicateA_(1000).as(ok) } } @@ -157,7 +289,7 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { private def parallel(dispatcher: Resource[IO, Dispatcher[IO]]) = { - common(dispatcher) + common(dispatcher, true) "run multiple IOs in parallel" in real { val num = 10 @@ -176,7 +308,7 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } } - rec.use(_ => IO.unit) + rec.use(_ => awaitAll) } } yield ok } @@ -201,37 +333,66 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } yield ok } - "forward cancelation onto the inner action" in real { - var canceled = false - - val rec = dispatcher flatMap { runner => - val run = IO { - runner.unsafeToFutureCancelable(IO.never.onCancel(IO { canceled = true }))._2 + // https://github.com/typelevel/cats-effect/issues/3898 + "not hang when cancelling" in real { + val test = dispatcher.use { dispatcher => + val action = IO.fromFuture { + IO { + val (_, cancel) = dispatcher.unsafeToFutureCancelable(IO.never) + cancel() + } } - Resource eval { - run.flatMap(ct => IO.sleep(500.millis) >> IO.fromFuture(IO(ct()))) - } + action.replicateA_(if (isJVM) 1000 else 1) } - TestControl.executeEmbed(rec.use(_ => IO(canceled must beTrue))) + if (isJVM) + test.parReplicateA_(100).as(ok) + else + test.as(ok) } - // https://github.com/typelevel/cats-effect/issues/3898 - "not hang when cancelling" in real { - dispatcher.use { dispatcher => - IO.fromFuture { - IO { - val (_, cancel) = dispatcher.unsafeToFutureCancelable(IO.never) - cancel() + "cancelation does not block a worker" in real { + TestControl executeEmbed { + dispatcher use { runner => + (IO.deferred[Unit], IO.deferred[Unit]) flatMapN { (latch1, latch2) => + val task = (latch1.complete(()) *> latch2.get).uncancelable + + IO(runner.unsafeToFutureCancelable(task)._2) flatMap { cancel => + latch1.get *> + IO(cancel()) *> + IO(runner.unsafeRunAndForget(latch2.complete(()))) *> + latch2.get.as(ok) + } } - }.replicateA_(1000) - .as(ok) + } } } + + "cancelation race does not block a worker" in real { + dispatcher + .use { runner => + IO.deferred[Unit] flatMap { latch => + val clogUp = IO { + val task = latch.get.uncancelable + runner.unsafeToFutureCancelable(task)._2 + }.flatMap { cancel => + // cancel concurrently + // We want to trigger race condition where task starts but then discovers it was canceled + IO(cancel()) + } + + clogUp.parReplicateA_(1000) *> + // now try to run a new task + IO.fromFuture(IO(runner.unsafeToFuture(latch.complete(())))) + } + } + .replicateA_(if (isJVM) 1000 else 1) + .as(ok) + } } - private def common(dispatcher: Resource[IO, Dispatcher[IO]]) = { + private def common(dispatcher: Resource[IO, Dispatcher[IO]], cancelable: Boolean) = { "run a synchronous IO" in real { val ioa = IO(1).map(_ + 2) @@ -250,9 +411,8 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } "run several IOs back to back" in real { - @volatile - var counter = 0 - val increment = IO(counter += 1) + val counter = new AtomicInteger(0) + val increment = IO(counter.getAndIncrement()).void val num = 10 @@ -260,7 +420,7 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { Resource.eval(IO.fromFuture(IO(runner.unsafeToFuture(increment))).replicateA(num).void) } - rec.use(_ => IO(counter mustEqual num)) + rec.use(_ => IO(counter.get() mustEqual num)) } "raise an error on leaked runner" in real { @@ -339,47 +499,24 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { } "reject new tasks while shutting down" in real { - (IO.ref(false), IO.ref(false)) - .flatMapN { (resultR, rogueResultR) => - dispatcher - .allocated - .flatMap { - case (runner, release) => - IO(runner.unsafeRunAndForget( - IO.sleep(1.second).uncancelable.guarantee(resultR.set(true)))) *> - IO.sleep(100.millis) *> - release.both( - IO.sleep(500.nanos) *> - IO(runner.unsafeRunAndForget(rogueResultR.set(true))).attempt - ) - } - .flatMap { - case (_, rogueSubmitResult) => - for { - result <- resultR.get - rogueResult <- rogueResultR.get - _ <- IO(result must beTrue) - _ <- IO(if (rogueResult == false) { - // if the rogue task is not completed then we must have failed to submit it - rogueSubmitResult must beLeft - () - }) - } yield ok - } - } - .replicateA(5) - } - - "issue 3501: reject new tasks after release action is submitted as a task" in ticked { - implicit ticker => - val test = dispatcher.allocated.flatMap { + val test = (IO.deferred[Unit], IO.deferred[Unit]) flatMapN { (latch1, latch2) => + dispatcher.allocated flatMap { case (runner, release) => - IO(runner.unsafeRunAndForget(release)) *> - IO.sleep(100.millis) *> - IO(runner.unsafeRunAndForget(IO(ko)) must throwAn[IllegalStateException]) + for { + _ <- IO( + runner.unsafeRunAndForget(IO.unit.guarantee(latch1.complete(()) >> latch2.get))) + _ <- latch1.get + + challenge = IO(runner.unsafeRunAndForget(IO.unit)) + .delayBy(500.millis) // gross sleep to make sure we're actually in the release + .guarantee(latch2.complete(()).void) + + _ <- release &> challenge + } yield ko } + } - test.void must completeAs(()) + test.attempt.flatMap(r => IO(r must beLeft)).parReplicateA_(50).as(ok) } "cancel inner awaits when canceled" in ticked { implicit ticker => @@ -388,6 +525,86 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { test must completeAs(()) } + + if (!cancelable) { + "ignore action cancelation" in real { + var canceled = false + + val rec = dispatcher flatMap { runner => + val run = IO { + runner + .unsafeToFutureCancelable(IO.sleep(500.millis).onCancel(IO { canceled = true })) + ._2 + } + + Resource eval { + run.flatMap(ct => IO.sleep(200.millis) >> IO.fromFuture(IO(ct()))) + } + } + + TestControl.executeEmbed(rec.use(_ => IO(canceled must beFalse))) + } + } else { + "forward cancelation onto the inner action" in real { + val test = dispatcher use { runner => + IO.ref(false) flatMap { resultsR => + val action = IO.never.onCancel(resultsR.set(true)) + IO(runner.unsafeToFutureCancelable(action)) flatMap { + case (_, cancel) => + IO.sleep(500.millis) *> IO.fromFuture(IO(cancel())) *> resultsR.get + } + } + } + + TestControl.executeEmbed(test).flatMap(b => IO(b must beTrue)) + } + + "support multiple concurrent cancelations" in real { + dispatcher use { runner => + val count = new AtomicInteger(0) + + for { + latch0 <- IO.deferred[Unit] + latch1 <- IO.deferred[Unit] + latch2 <- IO.deferred[Unit] + + action = (latch0.complete(()) *> IO.never) + .onCancel(latch1.complete(()) *> latch2.get) + + pair <- IO(runner.unsafeToFutureCancelable(action)) + (_, cancel) = pair + + _ <- latch0.get + + ec <- IO.executionContext + cancelAction = IO(cancel().onComplete(_ => count.getAndIncrement())(ec)) + _ <- cancelAction + _ <- cancelAction + _ <- cancelAction + + _ <- latch1.get + _ <- IO.sleep(100.millis) + _ <- IO(count.get() mustEqual 0) + + _ <- latch2.complete(()) + _ <- IO.sleep(100.millis) + _ <- IO(count.get() mustEqual 3) + } yield ok + } + } + + "complete / cancel race" in real { + val tsk = dispatcher.use { dispatcher => + IO.fromFuture(IO { + val (_, cancel) = dispatcher.unsafeToFutureCancelable(IO.unit) + val cancelFut = cancel() + cancelFut + }) + } + + tsk.replicateA_(if (isJVM) 10000 else 1).as(ok) + } + } } private def awaitTermination(dispatcher: Resource[IO, Dispatcher[IO]]) = { @@ -422,11 +639,13 @@ class DispatcherSpec extends BaseSpec with DetectPlatform { "issue #3506: await unsafeRunAndForget" in ticked { implicit ticker => val result = for { - resultR <- IO.ref(false) - _ <- dispatcher.use { runner => IO(runner.unsafeRunAndForget(resultR.set(true))) } - result <- resultR.get - } yield result - result must completeAs(true) + latch <- IO.deferred[Unit] + + repro = (latch.complete(()) >> IO.never).uncancelable + _ <- dispatcher.use(runner => IO(runner.unsafeRunAndForget(repro)) >> latch.get) + } yield () + + result must nonTerminate } "cancel active fibers when an error is produced" in real { diff --git a/tests/shared/src/test/scala/cats/effect/std/EnvSpec.scala b/tests/shared/src/test/scala/cats/effect/std/EnvSpec.scala index adbefb5355..dd98329325 100644 --- a/tests/shared/src/test/scala/cats/effect/std/EnvSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/EnvSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/HotswapSpec.scala b/tests/shared/src/test/scala/cats/effect/std/HotswapSpec.scala index e78434489d..1eb6fa8f8f 100644 --- a/tests/shared/src/test/scala/cats/effect/std/HotswapSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/HotswapSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/MapRefSpec.scala b/tests/shared/src/test/scala/cats/effect/std/MapRefSpec.scala index 8312af8474..2ee9166631 100644 --- a/tests/shared/src/test/scala/cats/effect/std/MapRefSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/MapRefSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/MutexSpec.scala b/tests/shared/src/test/scala/cats/effect/std/MutexSpec.scala index 8748af8b8e..e92deffd22 100644 --- a/tests/shared/src/test/scala/cats/effect/std/MutexSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/MutexSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/PQueueSpec.scala b/tests/shared/src/test/scala/cats/effect/std/PQueueSpec.scala index 725cbb70af..9824cfc117 100644 --- a/tests/shared/src/test/scala/cats/effect/std/PQueueSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/PQueueSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/QueueSpec.scala b/tests/shared/src/test/scala/cats/effect/std/QueueSpec.scala index 965cd6a35d..6bdf3a42c2 100644 --- a/tests/shared/src/test/scala/cats/effect/std/QueueSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/QueueSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -376,6 +376,7 @@ class UnboundedQueueSpec extends BaseSpec with QueueTests[Queue] { commonTests(_ => constructor, _.offer(_), _.tryOffer(_), _.take, _.tryTake, _.size) batchTakeTests(_ => constructor, _.offer(_), _.tryTakeN(_)) batchOfferTests(_ => constructor, _.tryOfferN(_), _.tryTakeN(_)) + cancelableTakeTests(_ => constructor, _.offer(_), _.take) } } diff --git a/tests/shared/src/test/scala/cats/effect/std/RandomSpec.scala b/tests/shared/src/test/scala/cats/effect/std/RandomSpec.scala index e6e0d8e7c2..039f7a30d4 100644 --- a/tests/shared/src/test/scala/cats/effect/std/RandomSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/RandomSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/SecureRandomSpec.scala b/tests/shared/src/test/scala/cats/effect/std/SecureRandomSpec.scala index 34f4ccfac7..ffc3dccd42 100644 --- a/tests/shared/src/test/scala/cats/effect/std/SecureRandomSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/SecureRandomSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/SemaphoreSpec.scala b/tests/shared/src/test/scala/cats/effect/std/SemaphoreSpec.scala index b7c387eb69..43d4c46647 100644 --- a/tests/shared/src/test/scala/cats/effect/std/SemaphoreSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/SemaphoreSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/SupervisorSpec.scala b/tests/shared/src/test/scala/cats/effect/std/SupervisorSpec.scala index 0ce590a6a3..d33f6e8030 100644 --- a/tests/shared/src/test/scala/cats/effect/std/SupervisorSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/SupervisorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,13 @@ package cats.effect package std +import cats.syntax.all._ + import org.specs2.specification.core.Fragments import scala.concurrent.duration._ -class SupervisorSpec extends BaseSpec { +class SupervisorSpec extends BaseSpec with DetectPlatform { "Supervisor" should { "concurrent" >> { @@ -213,7 +215,7 @@ class SupervisorSpec extends BaseSpec { } // if this doesn't work properly, the test will hang - test.start.flatMap(_.join).as(ok).timeoutTo(2.seconds, IO(false must beTrue)) + test.start.flatMap(_.join).as(ok).timeoutTo(4.seconds, IO(false must beTrue)) } "cancel inner fiber and ignore restart if outer errored" in real { @@ -227,7 +229,70 @@ class SupervisorSpec extends BaseSpec { } // if this doesn't work properly, the test will hang - test.start.flatMap(_.join).as(ok).timeoutTo(2.seconds, IO(false must beTrue)) + test.start.flatMap(_.join).as(ok).timeoutTo(4.seconds, IO(false must beTrue)) + } + + "supervise / finalize race" in real { + superviseFinalizeRace(constructor(false, None), IO.never[Unit]) + } + + "supervise / finalize race with checkRestart" in real { + superviseFinalizeRace(constructor(false, Some(_ => true)), IO.canceled) + } + + def superviseFinalizeRace(mkSupervisor: Resource[IO, Supervisor[IO]], task: IO[Unit]) = { + val tsk = IO.uncancelable { poll => + mkSupervisor.allocated.flatMap { + case (supervisor, close) => + supervisor.supervise(IO.never[Unit]).replicateA(100).flatMap { fibers => + val tryFork = supervisor.supervise(task).map(Some(_)).recover { + case ex: IllegalStateException => + ex.getMessage mustEqual "supervisor already shutdown" + None + } + IO.both(tryFork, close).flatMap { + case (maybeFiber, _) => + def joinAndCheck(fib: Fiber[IO, Throwable, Unit]) = + fib.join.flatMap { oc => IO(oc.isCanceled must beTrue) } + poll(fibers.traverse(joinAndCheck) *> { + maybeFiber match { + case None => + IO.unit + case Some(fiber) => + // `supervise` won the race, so our fiber must've been cancelled: + joinAndCheck(fiber) + } + }) + } + } + } + } + tsk.parReplicateA_(if (isJVM) 700 else 1).as(ok) + } + + "submit to closed supervisor" in real { + constructor(false, None).use(IO.pure(_)).flatMap { leaked => + leaked.supervise(IO.unit).attempt.flatMap { r => + IO(r must beLeft(beAnInstanceOf[IllegalStateException])) + } + } + } + + "restart / cancel race" in real { + val tsk = constructor(false, Some(_ => true)).use { supervisor => + IO.ref(0).flatMap { counter => + supervisor.supervise(counter.update(_ + 1) *> IO.canceled).flatMap { adaptedFiber => + IO.sleep(100.millis) *> adaptedFiber.cancel *> adaptedFiber.join *> ( + (counter.get, IO.sleep(100.millis) *> counter.get).flatMapN { + case (v1, v2) => + IO(v1 mustEqual v2) + } + ) + } + } + } + + tsk.parReplicateA_(if (isJVM) 1000 else 1).as(ok) } } } diff --git a/tests/shared/src/test/scala/cats/effect/std/UUIDGenSpec.scala b/tests/shared/src/test/scala/cats/effect/std/UUIDGenSpec.scala index ea39141a82..07d0a2a1dd 100644 --- a/tests/shared/src/test/scala/cats/effect/std/UUIDGenSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/UUIDGenSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/UnsafeBoundedSpec.scala b/tests/shared/src/test/scala/cats/effect/std/UnsafeBoundedSpec.scala index a83233cfd4..6905fbb123 100644 --- a/tests/shared/src/test/scala/cats/effect/std/UnsafeBoundedSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/UnsafeBoundedSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/UnsafeUnboundedSpec.scala b/tests/shared/src/test/scala/cats/effect/std/UnsafeUnboundedSpec.scala index b3fdb601f0..a655c11364 100644 --- a/tests/shared/src/test/scala/cats/effect/std/UnsafeUnboundedSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/UnsafeUnboundedSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/internal/BankersQueueSpec.scala b/tests/shared/src/test/scala/cats/effect/std/internal/BankersQueueSpec.scala index 931e548ae2..5224b7d2a8 100644 --- a/tests/shared/src/test/scala/cats/effect/std/internal/BankersQueueSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/internal/BankersQueueSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/std/internal/BinomialHeapSpec.scala b/tests/shared/src/test/scala/cats/effect/std/internal/BinomialHeapSpec.scala index d934204f1e..2b50cddb3f 100644 --- a/tests/shared/src/test/scala/cats/effect/std/internal/BinomialHeapSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/std/internal/BinomialHeapSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/testkit/TestControlSpec.scala b/tests/shared/src/test/scala/cats/effect/testkit/TestControlSpec.scala index db565f0a35..7f1ee0c736 100644 --- a/tests/shared/src/test/scala/cats/effect/testkit/TestControlSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/testkit/TestControlSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/tracing/TraceSpec.scala b/tests/shared/src/test/scala/cats/effect/tracing/TraceSpec.scala index fc235b2f6e..641ca350ff 100644 --- a/tests/shared/src/test/scala/cats/effect/tracing/TraceSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/tracing/TraceSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/tracing/TracingSpec.scala b/tests/shared/src/test/scala/cats/effect/tracing/TracingSpec.scala index 2b8a770a77..b143b1ed59 100644 --- a/tests/shared/src/test/scala/cats/effect/tracing/TracingSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/tracing/TracingSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeBuilderSpec.scala b/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeBuilderSpec.scala index c72c06fd79..4a15824150 100644 --- a/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeBuilderSpec.scala +++ b/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeBuilderSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Typelevel + * Copyright 2020-2024 Typelevel * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeConfigSpec.scala b/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeConfigSpec.scala new file mode 100644 index 0000000000..f3ad1db7cf --- /dev/null +++ b/tests/shared/src/test/scala/cats/effect/unsafe/IORuntimeConfigSpec.scala @@ -0,0 +1,59 @@ +/* + * Copyright 2020-2024 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cats.effect +package unsafe + +import scala.util.Try + +class IORuntimeConfigSpec extends BaseSpec { + + "IORuntimeConfig" should { + + "Reject invalid values of cancelation check- and auto yield threshold" in { + Try( + IORuntimeConfig( + cancelationCheckThreshold = -1, + autoYieldThreshold = -1)) must beFailedTry + Try( + IORuntimeConfig( + cancelationCheckThreshold = -1, + autoYieldThreshold = -2)) must beFailedTry + Try( + IORuntimeConfig(cancelationCheckThreshold = 0, autoYieldThreshold = 2)) must beFailedTry + Try( + IORuntimeConfig(cancelationCheckThreshold = 1, autoYieldThreshold = 1)) must beFailedTry + Try( + IORuntimeConfig(cancelationCheckThreshold = 2, autoYieldThreshold = 3)) must beFailedTry + Try( + IORuntimeConfig(cancelationCheckThreshold = 4, autoYieldThreshold = 2)) must beFailedTry + // these are fine: + IORuntimeConfig(cancelationCheckThreshold = 1, autoYieldThreshold = 2) + IORuntimeConfig(cancelationCheckThreshold = 1, autoYieldThreshold = 3) + IORuntimeConfig(cancelationCheckThreshold = 2, autoYieldThreshold = 2) + IORuntimeConfig(cancelationCheckThreshold = 2, autoYieldThreshold = 4) + ok + } + + "Reject invalid values even in the copy method" in { + val cfg = IORuntimeConfig(cancelationCheckThreshold = 1, autoYieldThreshold = 2) + Try(cfg.copy(cancelationCheckThreshold = 0)) must beFailedTry + Try(cfg.copy(cancelationCheckThreshold = -1)) must beFailedTry + Try(cfg.copy(autoYieldThreshold = 1)) must beFailedTry + Try(cfg.copy(cancelationCheckThreshold = 2, autoYieldThreshold = 3)) must beFailedTry + } + } +}