trait ReadWrite[F[_], A] extends AnyRef
A purely functional ReadWriteLock.
It declare that only a single writer at a time can modify the data, and predefined count of readers can concurrently read the data.
In other cases, it will be semantically blocked until operation become available. All those wishing to access the data are serviced in order.
- Alphabetic
- By Inheritance
- ReadWrite
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def get: F[A]
Like
read
, but does not require explicit release.Like
read
, but does not require explicit release.- returns
value snapshot
- abstract def modify[B](f: (A) => (A, B)): F[B]
Like
tryModify
but does not complete until the update has been successfully made. - abstract def read: F[(A, F[Unit])]
Acquires a single reader if there is no writers in queue and if the max number of readers is not reached.
Acquires a single reader if there is no writers in queue and if the max number of readers is not reached.
Otherwise, it will be semantically blocked until operation become available.
WARN! Ignoring release action lead to resource leak. In most cases,
get
is preferable.- returns
current value and release action.
- abstract def tryGet: F[Option[A]]
Like
tryRead
, but does not require explicit releaseLike
tryRead
, but does not require explicit release- returns
value snapshot wrapped in
Some
orNone
if reading is unavailable.
- abstract def tryModify[B](f: (A) => (A, B)): F[Option[B]]
Like
tryUpdate
but allows the update function to return an output value of typeB
.Like
tryUpdate
but allows the update function to return an output value of typeB
. The returned action completes withNone
if the value is not updated successfully andSome(b)
otherwise. - abstract def tryRead: F[Option[(A, F[Unit])]]
Acquires a single reader if there is no writers in queue and if the max number of readers is not reached.
Acquires a single reader if there is no writers in queue and if the max number of readers is not reached.
If not, None will be returned as a result.
- returns
current value and release action wrapped in
Some
orNone
if reading is unavailable.
- abstract def tryUpdate(f: (A) => A): F[Boolean]
Attempts to modify the current value with supplied function, returning
false
if writing is unavailable.Attempts to modify the current value with supplied function, returning
false
if writing is unavailable.- returns
whether or not the update succeeded
- abstract def tryWrite: F[Option[(A, (A) => F[Unit])]]
Acquires a single writer if there is no writers in queue and no one is reading.
Acquires a single writer if there is no writers in queue and no one is reading.
Or else,
None
will be returned as a result.- returns
current value and putAndRelease action wrapped in
Some
orNone
if writing is unavailable.
- abstract def update(f: (A) => A): F[Unit]
Modifies the current value using the supplied update function.
Modifies the current value using the supplied update function.
In scenarios where write operation is unavailable it may semantically blocks until operation successfully made.
- returns
a task that update state value on evaluation.
- abstract def write: F[(A, (A) => F[Unit])]
Acquires a single writer if there is no writers in queue and no one is reading.
Acquires a single writer if there is no writers in queue and no one is reading.
Otherwise, it will be semantically blocked until operation become available.
WARN! Ignoring putAndRelease action lead to resource leak. In most cases,
update
orset
is preferable.- returns
current value and putAndRelease action.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- 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()
- def set(a: A): F[Unit]
Sets the current value to
a
.Sets the current value to
a
.In scenarios where write operation is unavailable it may semantically blocks until operation successfully made.
- returns
a task that update state value to
a
on evaluation.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def trySet(a: A): F[Boolean]
Sets the current value to
a
.Sets the current value to
a
.In scenarios where write operation is unavailable it may semantically blocks until operation successfully made.
- returns
whether or not the update succeeded
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()