Skip to content

Commit

Permalink
Fixes (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru committed May 19, 2022
1 parent c688df5 commit 518b8da
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
6 changes: 2 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
))
Expand All @@ -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)

// --------------------------------------------
Expand All @@ -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)
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -141,16 +141,18 @@ 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))
*
* def dequeue(): Option[A] =
* state.transformAndExtract { queue =>
* if (queue.isEmpty)
* (None, queue)
* else
* (Some(queue.dequeue), queue)
* else {
* val (a, update) = queue.dequeue
* (Some(a), update)
* }
* }
* }
* }}}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 518b8da

Please sign in to comment.