abstract class Atomic[A] extends Serializable
Base trait of all atomic references, no matter the type.
- Source
- Atomic.scala
- Alphabetic
- By Inheritance
- Atomic
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Atomic()
Abstract Value Members
-
abstract
def
compareAndSet(expect: A, update: A): Boolean
Does a compare-and-set operation on the current value.
Does a compare-and-set operation on the current value. For more info, checkout the related Compare-and-swap Wikipedia page.
It's an atomic, worry free operation.
- expect
is the value you expect to be persisted when the operation happens
- update
will be the new value, should the check for
expect
succeeds- returns
either true in case the operation succeeded or false otherwise
-
abstract
def
get: A
Get the current value persisted by this Atomic.
-
abstract
def
getAndSet(update: A): A
Sets the persisted value to
update
and returns the old value that was in place.Sets the persisted value to
update
and returns the old value that was in place. It's an atomic, worry free operation. -
abstract
def
lazySet(update: A): Unit
Eventually sets to the given value.
Eventually sets to the given value. Has weaker visibility guarantees than the normal
set()
. -
abstract
def
set(update: A): Unit
Updates the current value.
Updates the current value.
- update
will be the new value returned by
get()
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final macro
def
:=(value: A): Unit
Alias for set.
Alias for set. Updates the current value.
- value
will be the new value returned by
get()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final macro
def
apply(): A
Get the current value persisted by this Atomic, an alias for
get()
. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final macro
def
getAndTransform(cb: (A) ⇒ A): A
Abstracts over
compareAndSet
.Abstracts over
compareAndSet
. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.
- cb
is a callback that receives the current value as input and returns the
update
which is the new value that should be persisted- returns
the old value, just prior to when the successful update happened
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final macro
def
transform(cb: (A) ⇒ A): Unit
Abstracts over
compareAndSet
.Abstracts over
compareAndSet
. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.
- cb
is a callback that receives the current value as input and returns the
update
which is the new value that should be persisted
-
final macro
def
transformAndExtract[U](cb: (A) ⇒ (U, A)): U
Abstracts over
compareAndSet
.Abstracts over
compareAndSet
. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by your callback.Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.
- cb
is a callback that receives the current value as input and returns a tuple that specifies the update + what should this method return when the operation succeeds.
- returns
whatever was specified by your callback, once the operation succeeds
-
final macro
def
transformAndGet(cb: (A) ⇒ A): A
Abstracts over
compareAndSet
.Abstracts over
compareAndSet
. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.
- cb
is a callback that receives the current value as input and returns the
update
which is the new value that should be persisted- returns
whatever the update is, after the operation succeeds
-
final macro
def
update(value: A): Unit
Alias for set.
Alias for set. Updates the current value.
- value
will be the new value returned by
get()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomic
types, as alternative tojava.util.concurrent.atomic
monix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observable
pattern:Observable
implementationsmonix.types implements type-class shims, to be translated to type-classes provided by libraries such as Cats or Scalaz.
monix.cats is the optional integration with the Cats library, providing translations for the types described in
monix.types
.monix.scalaz is the optional integration with the Scalaz library, providing translations for the types described in
monix.types
.