Packages

  • package root
    Definition Classes
    root
  • package io

    This is the documentation for the ThreadCSO Library.

    This is the documentation for the ThreadCSO Library. Notable packages include:

    Definition Classes
    root
  • package threadcso

    The standard threadCSO API.

    The standard threadCSO API. Most modules using CSO will need only the declaration:

    import io.threadcso._

    The present version of the ThreadCSO library API is 1.2Rr (for some number r)

    The revision number (Rr) will change if bugs are corrected but the code remains consistent with the previous API. Its minor version number will change if there is a correction to the code that breaks consistency with the previous API. Its major version will change if there is a substantial change in the semantics of an important CSO construct.

    August 2017: changes 1.1 => 1.2

    • renaming of very many internal classes and packages
    • basic channel implementations are more efficient, in some case much more so
    • alternation reliability improved
    • debugger registration of alternations is no longer needed
    • home-grown semaphores can specify which component they are part of: this makes interpreting a stack backtrace very much easier
    • there is a flexible logging system that is compatible with the debugger

    April 2016: changes 1.0 => 1.1

    • Extended rendezvous read operator is now ?? (was ?)
    • Extended rendezvous read event notation is now =??=> (was =?=>>)
    • The notation inport ? f is now equivalent to f(inport?()) This makes for a tidier layout when the function f is an explicit functional expression.

    Feb 1 2017: changes 1.1R1 => 1.1R2

    • Removed dependencies on deprecated Java->Scala functions: replaced with .asJava
    @author Bernard Sufrin, Oxford
    $Revision: 286 $
    $Date: 2017-11-18 17:41:30 +0000 (Sat, 18 Nov 2017) $
    Definition Classes
    io
  • package semaphore
    Definition Classes
    threadcso
  • package jdk
    Definition Classes
    semaphore
  • BooleanSemaphore
  • CountingSemaphore

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 releases 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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BooleanSemaphore
  2. CountingSemaphore
  3. Semaphore
  4. Debuggable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. 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

  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. 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
    BooleanSemaphoreCountingSemaphoreSemaphore
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. 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
    CountingSemaphoreSemaphore
  7. def cancelled(): Boolean

    True if the most recent semaphore acquisition was cancelled

    True if the most recent semaphore acquisition was cancelled

    Definition Classes
    CountingSemaphoreSemaphore
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def down(): Unit

    same as acquire

    same as acquire

    Definition Classes
    Semaphore
    Annotations
    @inline()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  14. 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
    CountingSemaphoreSemaphoreDebuggable
  15. 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
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. 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
  19. var name: String
    Definition Classes
    CountingSemaphore
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  23. def reInitialize(): Unit
    Definition Classes
    CountingSemaphore
  24. def register(): Unit

    Register this object

    Register this object

    Definition Classes
    Debuggable
  25. 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
    BooleanSemaphoreCountingSemaphoreSemaphore
  26. 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
  27. 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
    BooleanSemaphoreCountingSemaphoreDebuggable
  28. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  29. def toString(): String
    Definition Classes
    BooleanSemaphoreCountingSemaphore → AnyRef → Any
  30. 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
    BooleanSemaphoreCountingSemaphoreSemaphore
  31. def unregister(): Unit

    Unregister this object

    Unregister this object

    Definition Classes
    Debuggable
  32. def up(): Unit

    same as release

    same as release

    Definition Classes
    Semaphore
    Annotations
    @inline()
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. def withDebugger[T](condition: Boolean)(body: ⇒ T): T

    Conditionally register this object with the debugger only for the duration of the evaluation of body.

    Conditionally register this object with the debugger only for the duration of the evaluation of body. To be used as a last resort for the exasperated CSO toolkit debugger.

    Definition Classes
    Debuggable

Inherited from CountingSemaphore

Inherited from Semaphore

Inherited from debug.REGISTRY.Debuggable

Inherited from AnyRef

Inherited from Any

Ungrouped