trait Lock extends AnyRef
A trait for a non-blocking lock that ensures a synchronous execution schedule for all callers. A caller calls the lock method to execute a task synchronously once the lock is available. Simultaneous tasks are placed in a FIFO queue while awaiting execution.
Note1: Because Lock accepts a function to the task to run, it is not possible for callers to double lock, double release or forget to release the lock. Note2: Lock is NOT reentrant Note3: Lock should never be used when other locking options make more sense. Lock is designed for synchronizing many tasks (100+) and/or long running tasks (10ms+). Unlike other locking options, Lock does not block and consume a thread while waiting for the lock to become available. However, Lock is not the most performant option.
- Alphabetic
- By Inheritance
- Lock
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
isUnlocked: Boolean
- returns
TRUE if the lock is available
-
abstract
def
lock[X](task: ⇒ Future[X])(implicit ec: ExecutionContext): DeferredFuture[X]
- returns
a future that completes once the lock is available AND task completes. The lock is locked while task is running and after task completes it is unlocked.
-
abstract
def
waitQueueLength: Int
- returns
the count of callers waiting on the lock to become available
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[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @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
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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
- @throws( ... )