Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref docs #3047

Merged
merged 4 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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