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 alternation
    Definition Classes
    threadcso
  • package basis

    A home for types that are needed more or less pervasively.

    A home for types that are needed more or less pervasively.

    @author Bernard Sufrin, Oxford
    $Revision: 228 $
    $Date: 2016-03-04 16:11:56 +0000 (Fri, 04 Mar 2016)
    Definition Classes
    threadcso
  • package channel

    Specifies primitive (non-alternation-capable) ports and channels; and implements several channel types.

    Specifies primitive (non-alternation-capable) ports and channels; and implements several channel types.

    Definition Classes
    threadcso
  • package component

    A collection of several process-generators that (mostly) yield processes to work on (or produce) finite or infinite streams of values presented as channel.

    A collection of several process-generators that (mostly) yield processes to work on (or produce) finite or infinite streams of values presented as channel. All are designed to terminate cleanly -- 'i.e.' to closeIn or closeOut all the channel.that they communicate on in the appropriate direction for the type of port.

    Some of these components were inspired by (or copied from) components from the Plug'n'Play collection of JCSP (without necessarily retaining the P'n'P names).

    @version 03.20120824
    @author Bernard Sufrin, Oxford
    $Revision: 247 $
    $Date: 2017-10-20 15:00:00 +0100 (Fri, 20 Oct 2017) $
    Definition Classes
    threadcso
  • package debug
    Definition Classes
    threadcso
  • package lock
    Definition Classes
    threadcso
  • package monitor
    Definition Classes
    threadcso
  • AbstractMonitor
  • FairMonitor
  • Monitor
  • package process
    Definition Classes
    threadcso
  • package semaphore
    Definition Classes
    threadcso
p

io.threadcso

monitor

package monitor

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class AbstractMonitor extends debug.REGISTRY.Debuggable

    Abstract precursor of monitor implementations that use jdk.util.concurrent.lock classes.

    Abstract precursor of monitor implementations that use jdk.util.concurrent.lock classes. If fair is true then the lock is first-come first-served. Under heavy contention this can be useful, but it appears to impose a penalty of (around) a factor of 10 in the elapsed time to acquisition of the lock.

    If a monitor is registered with the debugger its state will be shown in a debugger snapshot if its lock is owned (or awaited) at the time of the snapshot. This can be helpful for in-extremis debugging.

    Objects that use one of these monitor as a source of Conditions in their implementation must themselves register with the debugger and must themselves implement the debugger's hasState/showState/getWaiting/ protocol.

    The following is an implementation of a one-slot buffer using two condition queues so that multiple producer (consumer) processes can invoke put (get).

    class MonitorSlot[T] extends Slot[T] {
      private [this] val monitor = new Monitor
      private [this] var value: T            = _
      private [this] var empty               = true
      private [this] val isEmpty, isNonEmpty = monitor.newCondition
    
      def put(v: T) = monitor withLock
      { while (!empty) isEmpty.await()
        value = v; empty = false
        isNonEmpty.signal()
      }
    
      def get: T = monitor withLock
      { while (empty) isNonEmpty.await()
        val result = value; empty = true
        isEmpty.signal()
        return result
      }
    }

    The following is an implementation of a one-slot buffer using just a single queue. Multiple producer (consumer) processes can still invoke put (get), but note the use of the (less efficient under load) signalAll method.

    class MonitorSlot2[T] extends Slot[T] {
      private [this] val monitor = new Monitor
      private [this] var value: T = _
      private [this] var empty    = true
      private [this] val waiting  = monitor.newCondition
    
      def put(v: T) = monitor withLock
      { while (!empty) waiting.await()
        value = v; empty = false
        waiting.signalAll()
      }
    
      def get: T = monitor withLock
      { while (empty) waiting.await()
        val result = value; empty = true
        waiting.signalAll()
        return result
      }
    }
  2. class FairMonitor extends AbstractMonitor

    A class that provides re-entrant first-come-first-served locking and condition variables

    A class that provides re-entrant first-come-first-served locking and condition variables

    See also

    io.threadcso.monitor.AbstractMonitor for usage

  3. class Monitor extends AbstractMonitor

    A class that provides re-entrant locking and condition variables

    A class that provides re-entrant locking and condition variables

    See also

    io.threadcso.monitor.AbstractMonitor for usage

Value Members

  1. object FairMonitor
  2. object Monitor

Ungrouped