monifu.concurrent.locks

NaiveReadWriteLock

final class NaiveReadWriteLock extends ReadWriteLock

Naive read-write lock, meant for low-contention scenarios.

Not a good idea to use it in high-contention scenarios, as the locking is unfair (i.e. writes have priority over reads, but otherwise it provides no guarantees to the fairness of what thread gets the lock next), plus spinlocking means that threads never wait and thus consume CPU resources.

Example:

class Fibonacci {
private[this] val lock = new NaiveReadWriteLock()
private[this] var a, b = 1

def get = lock.readLock(b)

def next() = lock.writeLock {
  val tmp = b
  b = a + b
  a = tmp
  get
}
}
Linear Supertypes
ReadWriteLock, Lock, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. NaiveReadWriteLock
  2. ReadWriteLock
  3. Lock
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def acquire[T](cb: ⇒ T): T

    Acquires a lock meant for both reading and writing.

    Acquires a lock meant for both reading and writing.

    Definition Classes
    ReadWriteLockLock
  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  16. def readLock[T](cb: ⇒ T): T

    Acquires a lock meant for reading.

    Acquires a lock meant for reading. Multiple threads can acquire the lock at the same time. It is also re-entrant (i.e. the same thread can acquire it multiple times)

    Definition Classes
    NaiveReadWriteLockReadWriteLock
    Annotations
    @throws( classOf[InterruptedException] )
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  18. def toString(): String

    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. def writeLock[T](cb: ⇒ T): T

    Acquires a lock meant for writing.

    Acquires a lock meant for writing. Only one thread can acquire the write lock at the same time and it has to wait until all active reads are finished.

    Definition Classes
    NaiveReadWriteLockReadWriteLock
    Annotations
    @throws( classOf[InterruptedException] )

Inherited from ReadWriteLock

Inherited from Lock

Inherited from AnyRef

Inherited from Any

Ungrouped