class BooleanSemaphore extends Semaphore
A fast boolean semaphore implemented with a nonblocking queue.
The object parent
(by default the semaphore itself) is
used by the debugger when reporting the state of waiting
processes.
The object parent
is shown by the debugger when doing stack backtraces.
The value spin
is the number of attempts the semaphore's inbuilt spinlock will make to seize the semaphore
before a call to acquire
or acquireFast
causes the caller to be descheduled. The point of
trying with a spinlock first is that the performance-hit of descheduling can be very high. We assume here
that more than one processor is available: set spin
to 0
or 1
otherwise.
The fair
parameter is ignored.
- To do
Make the internal spinlock adaptive
- Alphabetic
- By Inheritance
- BooleanSemaphore
- Semaphore
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new BooleanSemaphore(available: Boolean, name: String, fair: Boolean, parent: AnyRef, spin: Int = 5)
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(): Unit
Wait until the semaphore is unlocked.
Wait until the semaphore is unlocked. If the acquiring thread is cancelled during the wait or the semaphore's
cancel()
method has been called, then rethrow the cancel.- Definition Classes
- BooleanSemaphore → Semaphore
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- val available: Boolean
-
def
cancel(): Unit
"Interrupt" each thread waiting to acquire this semaphore, causing the
acquire
to terminate, withcancelled()
true."Interrupt" each thread waiting to acquire this semaphore, causing the
acquire
to terminate, withcancelled()
true.- Definition Classes
- BooleanSemaphore → Semaphore
-
def
cancelled(): Boolean
true if the semaphore has been cancelled during an
acquire
.true if the semaphore has been cancelled during an
acquire
.- Definition Classes
- BooleanSemaphore → Semaphore
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
down(): Unit
same as acquire
same as acquire
- Definition Classes
- Semaphore
- Annotations
- @inline()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val fair: Boolean
-
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
getWaiting: Seq[Thread]
Return an (approximate) list of the threads waiting to acquire a token from this semaphore.
Return an (approximate) list of the threads waiting to acquire a token from this semaphore. Intended for use only by diagnostic components.
- Definition Classes
- BooleanSemaphore → Semaphore
-
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
- val parent: AnyRef
-
def
release(): Unit
Unlock the semaphore and permit an
acquire
ing process to proceed.Unlock the semaphore and permit an
acquire
ing process to proceed.- Definition Classes
- BooleanSemaphore → Semaphore
-
def
remaining(): Int
Approximation to the number of acquires that could now succeed without having to wait.
Approximation to the number of acquires that could now succeed without having to wait. Intended for use only by diagnostic components.
- Definition Classes
- BooleanSemaphore → Semaphore
- val spin: Int
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- BooleanSemaphore → AnyRef → Any
-
def
tryAcquire(timeoutNS: Long): Boolean
Wait until the semaphore becomes available (returning true) or until the specified timeout has elapsed (returning false).
Wait until the semaphore becomes available (returning true) or until the specified timeout has elapsed (returning false). Unlike
java.util.concurrent.Semaphore
an invoking thread that needs to wait joins the queue of waiting threads -- threads with shorter timeouts are not prioritised over those with longer deadlines or no deadline. If the acquiring thread is cancelled during the wait or the semaphore'scancel()
method has been called, then thecancelled()
method will return true.- Definition Classes
- BooleanSemaphore → Semaphore
-
def
up(): Unit
same as release
same as release
- Definition Classes
- Semaphore
- Annotations
- @inline()
-
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( ... )