class AsyncMutex extends AsyncSemaphore
An AsyncMutex is a traditional mutex but with asynchronous execution.
Basic usage:
val mutex = new AsyncMutex() ... mutex.acquireAndRun() { somethingThatReturnsFutureT() }
- See also
AsyncSemaphore for a semaphore version.
- Alphabetic
- By Inheritance
- AsyncMutex
- AsyncSemaphore
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
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
- def acquire(): Future[Permit]
Acquire a Permit, asynchronously.
Acquire a Permit, asynchronously. Be sure to
permit.release()
in a-
finally
block of youronSuccess
callback -ensure
block of your future chainInterrupting this future is only advisory, and will not release the permit if the future has already been satisfied.
- returns
a
Future[Permit]
when theFuture
is satisfied, computation can proceed, or a Future.Exception[RejectedExecutionException]if the configured maximum number of waiters would be exceeded.
- Definition Classes
- AsyncSemaphore
- Note
This method always return the same instance of Permit.
- def acquireAndRun[T](func: => Future[T]): Future[T]
Execute the function asynchronously when a permit becomes available.
Execute the function asynchronously when a permit becomes available.
If the function throws a non-fatal exception, the exception is returned as part of the Future. For all exceptions, the permit would be released before returning.
- returns
a Future[T] equivalent to the return value of the input function. If the configured maximum value of waitq is reached, Future.Exception[RejectedExecutionException] is returned.
- Definition Classes
- AsyncSemaphore
- def acquireAndRunSync[T](func: => T): Future[T]
Execute the function when a permit becomes available.
Execute the function when a permit becomes available.
If the function throws an exception, the exception is returned as part of the Future. For all exceptions, the permit would be released before returning.
- returns
a Future[T] equivalent to the return value of the input function. If the configured maximum value of waitq is reached, Future.Exception[RejectedExecutionException] is returned.
- Definition Classes
- AsyncSemaphore
- 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 fail(exc: Throwable): Unit
Fail the semaphore and stop it from distributing further permits.
Fail the semaphore and stop it from distributing further permits. Subsequent attempts to acquire a permit fail with
exc
. This semaphore's queued waiters are also failed withexc
.- Definition Classes
- AsyncSemaphore
- 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 numInitialPermits: Int
- Definition Classes
- AsyncSemaphore
- def numPermitsAvailable: Int
- Definition Classes
- AsyncSemaphore
- def numWaiters: Int
- Definition Classes
- AsyncSemaphore
- 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(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()