Skip to content

Commit

Permalink
Merge pull request #3047 from TimWSpence/ref-docs
Browse files Browse the repository at this point in the history
Ref docs
  • Loading branch information
djspiewak authored Jun 25, 2022
2 parents 118d53f + 7daeb8a commit f949dae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/std/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ Provides safe concurrent access and modification of its content, but no function

For this reason, a `Ref` is always initialised to a value.

The default implementation is nonblocking and lightweight, consisting essentially of a purely functional wrapper over an `AtomicReference`.
The default implementation is nonblocking and lightweight, consisting
essentially of a purely functional wrapper over an `AtomicReference`.
Consequently it _must not_ be used to store mutable data as
`AtomicReference#compareAndSet` and friends are not threadsafe and are dependent
upon object reference equality.


### Concurrent Counter

Expand Down
4 changes: 3 additions & 1 deletion kernel/shared/src/main/scala/cats/effect/kernel/Ref.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import scala.annotation.tailrec
* initialised to a value.
*
* The default implementation is nonblocking and lightweight, consisting essentially of a purely
* functional wrapper over an `AtomicReference`.
* functional wrapper over an `AtomicReference`. Consequently it ''must not'' be used to store
* mutable data as `AtomicReference#compareAndSet` and friends are not threadsafe and are
* dependent upon object reference equality.
*/
abstract class Ref[F[_], A] extends RefSource[F, A] with RefSink[F, A] {

Expand Down

0 comments on commit f949dae

Please sign in to comment.