diff --git a/build.sbt b/build.sbt index 96c74260e..19da9d907 100644 --- a/build.sbt +++ b/build.sbt @@ -593,7 +593,7 @@ lazy val executionShadedJCTools = project lazy val executionAtomicProfile = crossModule( projectName = "monix-execution-atomic", - withDocTests = false, + withDocTests = true, crossSettings = Seq( description := "Sub-module of Monix, exposing low-level atomic references. See: https://monix.io", )) @@ -603,7 +603,7 @@ lazy val executionAtomicJVM = project.in(file("monix-execution/atomic/jvm")) .settings(macroDependencies) lazy val executionAtomicJS = project.in(file("monix-execution/atomic/js")) - .configure(executionProfile.js) + .configure(executionAtomicProfile.js) .settings(macroDependencies) // -------------------------------------------- @@ -622,7 +622,6 @@ lazy val executionProfile = lazy val executionJVM = project .in(file("monix-execution/jvm")) .configure(executionProfile.jvm) - .settings(macroDependencies) .dependsOn(executionShadedJCTools) .aggregate(executionAtomicJVM) .dependsOn(executionAtomicJVM) @@ -631,7 +630,6 @@ lazy val executionJVM = project lazy val executionJS = project .in(file("monix-execution/js")) .configure(executionProfile.js) - .settings(macroDependencies) .aggregate(executionAtomicJS) .dependsOn(executionAtomicJS) diff --git a/monix-execution/atomic/js/src/main/scala/monix/execution/atomic/package.scala b/monix-execution/atomic/js/src/main/scala/monix/execution/atomic/package.scala index 999c88406..86d8a5813 100644 --- a/monix-execution/atomic/js/src/main/scala/monix/execution/atomic/package.scala +++ b/monix-execution/atomic/js/src/main/scala/monix/execution/atomic/package.scala @@ -22,10 +22,7 @@ package monix.execution * On top of the JVM, this means dealing with lock-free thread-safe programming. Also works on top of Javascript, * with Scala.js, for API compatibility purposes and because it's a useful way to box a value. * - * The backbone of Atomic references is this method: - * {{{ - * def compareAndSet(expect: T, update: T): Boolean - * }}} + * The backbone of Atomic references is [[Atomic.compareAndSet]]. * * This method atomically sets a variable to the `update` value if it currently holds * the `expect` value, reporting `true` on success or `false` on failure. The classes in this package @@ -35,14 +32,16 @@ package monix.execution * return the most specific type needed (in the following sample, that's an `AtomicDouble`, * inheriting from `AtomicNumber[A]`): * {{{ + * import monix.execution.atomic._ + * * val atomicNumber = Atomic(12.2) - * * atomicNumber.incrementAndGet() * // => 13.2 * }}} * * These also provide useful helpers for atomically mutating of values - * (i.e. `transform`, `transformAndGet`, `getAndTransform`, etc...) or of numbers of any kind - * (`incrementAndGet`, `getAndAdd`, etc...). + * (i.e. [[Atomic.transform]], [[Atomic.transformAndGet]], [[Atomic.transformAndExtract]], + * etc.) or of numbers of any kind ([[AtomicNumber.incrementAndGet]], + * [[AtomicNumber.getAndAdd]], etc.). */ package object atomic diff --git a/monix-execution/atomic/jvm/src/main/scala/monix/execution/atomic/package.scala b/monix-execution/atomic/jvm/src/main/scala/monix/execution/atomic/package.scala index c57f80a67..52799f1dd 100644 --- a/monix-execution/atomic/jvm/src/main/scala/monix/execution/atomic/package.scala +++ b/monix-execution/atomic/jvm/src/main/scala/monix/execution/atomic/package.scala @@ -28,10 +28,7 @@ import monix.execution.atomic.internal.BoxPaddingStrategy * for API compatibility purposes and because it's a useful way to * box a value. * - * The backbone of Atomic references is this method: - * {{{ - * def compareAndSet(expect: T, update: T): Boolean - * }}} + * The backbone of Atomic references is this method: [[Atomic.compareAndSet]]. * * This method atomically sets a variable to the `update` value if it * currently holds the `expect` value, reporting `true` on success or @@ -44,16 +41,17 @@ import monix.execution.atomic.internal.BoxPaddingStrategy * `AtomicNumber[A]`): * * {{{ + * import monix.execution.atomic._ + * * val atomicNumber = Atomic(12.2) - * * atomicNumber.incrementAndGet() * // => 13.2 * }}} * - * These also provide useful helpers for atomically mutating of - * values (i.e. `transform`, `transformAndGet`, `getAndTransform`, - * etc...) or of numbers of any kind (`incrementAndGet`, `getAndAdd`, - * etc...). + * These also provide useful helpers for atomically mutating of values + * (i.e. [[Atomic.transform]], [[Atomic.transformAndGet]], [[Atomic.transformAndExtract]], + * etc.) or of numbers of any kind ([[AtomicNumber.incrementAndGet]], + * [[AtomicNumber.getAndAdd]], etc.). */ package object atomic { /** Internal utility for converting between padding strategy representations. */ diff --git a/monix-execution/atomic/shared/src/main/scala/monix/execution/atomic/internal/AtomicDocs.scala b/monix-execution/atomic/shared/src/main/scala/monix/execution/atomic/internal/AtomicDocs.scala index ef5146c41..b31484477 100644 --- a/monix-execution/atomic/shared/src/main/scala/monix/execution/atomic/internal/AtomicDocs.scala +++ b/monix-execution/atomic/shared/src/main/scala/monix/execution/atomic/internal/AtomicDocs.scala @@ -41,7 +41,7 @@ package internal * * def getAndSet[A](ref: Atomic[A], update: A): A = { * val current = ref.get() - * if (!compareAndSet(current, update)) + * if (!ref.compareAndSet(current, update)) * getAndSet(ref, update) // update failed, repeat! * else * current @@ -79,7 +79,7 @@ package internal * import monix.execution.atomic._ * import scala.collection.immutable.Queue * - * class ConcurrentQueue[A] private (ref: Atomic[Queue[A]]) { + * class ConcurrentQueue0[A] private (ref: Atomic[Queue[A]]) { * def enqueue(value: A): Unit = { * val current = ref.get() * val update = current.enqueue(value) @@ -141,7 +141,7 @@ package internal * import monix.execution.atomic._ * import scala.collection.immutable.Queue * - * final class ConcurrentQueue[A] private (state: AtomicRef[Queue[A]]) { + * final class ConcurrentQueue1[A] private (state: AtomicAny[Queue[A]]) { * def enqueue(value: A): Unit = * state.transform(_.enqueue(value)) * @@ -149,8 +149,10 @@ package internal * state.transformAndExtract { queue => * if (queue.isEmpty) * (None, queue) - * else - * (Some(queue.dequeue), queue) + * else { + * val (a, update) = queue.dequeue + * (Some(a), update) + * } * } * } * }}} @@ -190,7 +192,7 @@ package internal * {{{ * import monix.execution.atomic._ * - * final class CountDown private (state: AtomicLong) { + * final class CountDown0 private (state: AtomicLong) { * def next(): Boolean = { * val n = state.transformAndGet(n => math.max(n - 1, 0)) * n > 0 @@ -216,7 +218,7 @@ package internal * {{{ * import monix.execution.atomic._ * - * final class CountDown private (state: AtomicLong, n: Int) { + * final class CountDown1 private (state: AtomicLong, n: Int) { * def next(): Boolean = { * val i = state.getAndTransform(i => math.min(n, i + 1)) * i < n