class BooleanSemaphore extends CountingSemaphore
A classical boolean semaphore that manages a single virtual permit.
Each acquire
waits if necessary until the permit
is available, and then makes it unavailable (its "owner" is said to be the
process that last made it unavailable). A release
makes the permit available (if it wasn't already) to a waiting
process.
If the semaphore is fair
the semaphore will (under contention)
guarantee first-in first-out acquisition of the permit.
Fairness can impose very considerable delays.
A thread that release
s the permit need not have acquired it
previously.
This implementation delegates most of its implementation to java.util.concurrent.Semaphore
.
A BooleanSemaphore
can be registered with the debugger.
- Deprecated
Use io.threadcso.semaphore.CountingSemaphore instead unless you absolutely need the fairness parameter.
- Alphabetic
- By Inheritance
- BooleanSemaphore
- CountingSemaphore
- Semaphore
- Debuggable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
BooleanSemaphore(available: Boolean, _name: String = null, fair: Boolean = false, _register: Boolean = false)
- Deprecated
Use io.threadcso.semaphore.CountingSemaphore instead unless you absolutely need the fairness parameter.
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 a token is free, then remove it from the collection.
Wait until a token is free, then remove it from the collection.
- Definition Classes
- BooleanSemaphore → CountingSemaphore → Semaphore
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
cancel(): Unit
Optional: cancel all threads waiting to acquire the semaphore: defined only in io.threadcso.semaphore.BooleanSemaphore and io.threadcso.semaphore.CountingSemaphore
Optional: cancel all threads waiting to acquire the semaphore: defined only in io.threadcso.semaphore.BooleanSemaphore and io.threadcso.semaphore.CountingSemaphore
- Definition Classes
- CountingSemaphore → Semaphore
-
def
cancelled(): Boolean
True if the most recent semaphore acquisition was cancelled
True if the most recent semaphore acquisition was cancelled
- Definition Classes
- CountingSemaphore → 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
-
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
- CountingSemaphore → Semaphore → Debuggable
-
def
hasState: Boolean
This object has a state worth showing right now: false if showState will do no output.
This object has a state worth showing right now: false if showState will do no output.
- Definition Classes
- Debuggable
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
val
key: StateKey
This object's key in the registry (if non-negative)
This object's key in the registry (if non-negative)
- Definition Classes
- Debuggable
-
var
name: String
- Definition Classes
- CountingSemaphore
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
reInitialize(): Unit
- Definition Classes
- CountingSemaphore
-
def
register(): Unit
Register this object
Register this object
- Definition Classes
- Debuggable
-
def
release(): Unit
Release a token that may (but need not) have previously been acquired.
Release a token that may (but need not) have previously been acquired.
- Definition Classes
- BooleanSemaphore → CountingSemaphore → 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
- Semaphore
-
def
showState(out: PrintWriter): Unit
Show the current state of this object: default uses
toString
Show the current state of this object: default uses
toString
- Definition Classes
- BooleanSemaphore → CountingSemaphore → Debuggable
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- BooleanSemaphore → CountingSemaphore → AnyRef → Any
-
def
tryAcquire(wait: Long): Boolean
Optional: Wait until a token is free, or until
timeoutNS
nanoseconds have elapsed.Optional: Wait until a token is free, or until
timeoutNS
nanoseconds have elapsed. In the former case acquire a token and return true; in the latter case return false.- Definition Classes
- BooleanSemaphore → CountingSemaphore → Semaphore
-
def
unregister(): Unit
Unregister this object
Unregister this object
- Definition Classes
- Debuggable
-
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( ... )
-
def
withDebugger[T](condition: Boolean)(body: ⇒ T): T
Conditionally
register
this object with the debugger only for the duration of the evaluation ofbody
.Conditionally
register
this object with the debugger only for the duration of the evaluation ofbody
. To be used as a last resort for the exasperated CSO toolkit debugger.- Definition Classes
- Debuggable