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
  • ExtendCollection
  • package debug
    Definition Classes
    threadcso
  • package lock
    Definition Classes
    threadcso
  • package monitor
    Definition Classes
    threadcso
  • package process
    Definition Classes
    threadcso
  • package semaphore
    Definition Classes
    threadcso
p

io.threadcso

component

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. 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) $
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. component
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit class ExtendCollection [T] extends AnyRef

    An implicit class that equips an Iterable[T] collection with methods that write all its members to an output port.

    An implicit class that equips an Iterable[T] collection with methods that write all its members to an output port.

    I confess that this class is here only because ScalaDoc will not generate documentation for a channel unless it defines one or more class-like entities.

Value Members

  1. def Integrator(in: channel.?[Long], out: channel.![Long]): PROC

    A composite component that sums its input stream onto its output stream

    A composite component that sums its input stream onto its output stream

                   in                        out
    [x,y,z,...] >------>|\              /|---------> [x,x+y,x+y+z,...]
                        |+}----------->{ |
                    +-->|/              \|--+
                    |                       |
                    +----------<{(0)}<------+
  2. def Ticker(periodNS: Nanoseconds): ?[Unit]

    Generate a ?[Unit] to which an () is repeatedly written by a server process periodNS nanoseconds after it is read.

    Generate a ?[Unit] to which an () is repeatedly written by a server process periodNS nanoseconds after it is read.

    The server terminates at the next tick after the port is closed.

    +----------+
    | periodNS |>-------------> ()
    +----------+
  3. def Timer(periodNS: Nanoseconds, relativeTo: Nanoseconds = 0l): ?[Nanoseconds]

    Generate a ?[Nanoseconds] on which the system nanosecond clock is offered by a server process at least every periodNS nanoseconds.

    Generate a ?[Nanoseconds] on which the system nanosecond clock is offered by a server process at least every periodNS nanoseconds. The offer is withdrawn if the port is not read between the moment of the offer and the moment at which the next offer is due. For example:

    Ticker(seconds(10))

    yields a port that makes the absolute nanosecond clock available with a resolution of 10 seconds.

    The server terminates at the next tick after the port is closed.

    +----------+
    | periodNS |>-------------> ... System.nanotime ...
    +----------+
  4. def console[T](in: channel.?[T]): PROC

    Repeatedly write the string forms of values read from in onto the standard output stream.

  5. def const[T](ts: T*)(out: channel.![T]): PROC

    Output all the given ts onto the output port, then terminate.

    Output all the given ts onto the output port, then terminate.

    +------------+ t1, ...
    | t1, ... tn +--------->
    +------------+
  6. def copy[T](in: channel.?[T], out: channel.![T]): PROC

    Repeatedly copy values from in to out.

  7. def exchanger[T](l: channel.?[T], r: channel.?[T], lo: channel.![T], hi: channel.![T])(implicit arg0: (T) ⇒ Ordered[T]): PROC

    Repeatedly reads pairs inputs from its two input channel.and outputs them (in parallel, and ordered) to its two output channel.

    Repeatedly reads pairs inputs from its two input channel.and outputs them (in parallel, and ordered) to its two output channel.

    x, ...--->[\/]---> max(x,y), ...
    y, ...--->[/\]---> min(x,y), ...

    Here is a four-channel sorting network composed of 5 such components.

    -->[\/]--------->[\/]------------>
    -->[/\]---+  +-->[/\]--+
              |  |         |
              |  |         +-->[\/]-->
    -->[\/]------+         +-->[/\]-->
    -->[/\]-+ |            |
            | +---->[\/]---+
            +------>[/\]------------->
  8. def filter[T](pass: (T) ⇒ Boolean)(in: channel.?[T], out: channel.![T]): PROC

    Copy values from in to out that satisfy pass.

  9. def inj[T](in: ?[T], inj: ?[T], out: ![T]): PROC

    Merges the streams in and inj onto out, giving priority to data arriving on inj.

  10. def keyboard(out: channel.![String], prompt: ⇒ String): PROC

    Repeatedly output lines read from the standard input stream, stopping when out either does not accept an output or can no longer accept an output; and using the prompt thunk to generate a (new) prompt each time a line is to be read.

    Repeatedly output lines read from the standard input stream, stopping when out either does not accept an output or can no longer accept an output; and using the prompt thunk to generate a (new) prompt each time a line is to be read. Ending the standard input stream (Control-D to the terminal on Unix-based operating systems) causes out to be closed for output, as does closing the input port on the channel of which out is the output port.

  11. def keyboard(out: channel.![String]): PROC

    Repeatedly output lines read from the standard input stream, stopping when out either does not accept an output or can no longer accept an output.

    Repeatedly output lines read from the standard input stream, stopping when out either does not accept an output or can no longer accept an output. Ending the standard input stream (Control-D to the terminal on Unix-based operating systems) causes out to be closed for output, as does closing the input port on the channel of which out is the output port.

  12. def lines(pathName: String, out: channel.![String]): PROC

    Repeatedly output lines read from the file with the given path name

  13. def lines(file: File, out: channel.![String]): PROC

    Repeatedly output lines read from the given File

  14. def lines(in: Reader, out: channel.![String]): PROC

    Repeatedly output lines read from the given Reader.

  15. def lines(in: LineNumberReader, out: channel.![String]): PROC

    Repeatedly output lines read from the given LineNumberReader.

    Repeatedly output lines read from the given LineNumberReader.

    When in is associated with the user's terminal, rather than a file, there is a potential race condition that the code here does not forbid (explained below). Use keyboard(out) to play this role.

    The race condition results in an unnecessary invocation of in.readLine that will wait for input even though out is already closed.

    This happens when a program reading from the keyboard terminates and closes channel downstream of the keyboard. This leaves an unconsummated readLine waiting at the keyboard itself, that has to be cleared by typing an end-line or EOF character.

    The closing of out should really abort an in.readLine that is already in progress. But that would add unwarranted complexity to channel implementations.

  16. def map[I, O](f: (I) ⇒ O)(in: channel.?[I], out: channel.![O]): PROC

    x, ... >-->[f]>-->f(x), ...
  17. def merge[T](ins: Seq[?[T]], out: ![T]): PROC

    Merge several input streams Into a single output stream.

    Merge several input streams Into a single output stream. Terminate when the output stream, or all the input streams have closed.

      >---->|\  out
    ins :   | }----->
      >---->|/
  18. def prefix[T](ts: T*)(in: channel.?[T], out: channel.![T]): PROC

    Output the given ts to out, then copy values from in to out, respecting the network-termination convention.

  19. def sampler[T](periodNS: Long, in: ?[T], out: ![T]): PROC

    Read data from in as channel.as it appears there, copying the most-recently read datum to out every periodNS nanoseconds.

  20. def tail[T](in: channel.?[T], out: channel.![T]): PROC

    Drop the first value read from in, then copy values from in to out.

  21. def tee[T](in: channel.?[T], outs: channel.![T]*): PROC

    Copy from the given input stream to the given output streams, performing the outputs concurrently.

    Copy from the given input stream to the given output streams, performing the outputs concurrently. Terminate when the input stream or any of the output streams is closed.

             in   /|----> x, ...
    x, ... >---->{ | : outs
                  \|----> x, ...
  22. def zip[L, R](lin: channel.?[L], rin: channel.?[R], out: channel.![(L, R)]): PROC

    Turns a pair of streams into a stream of pairs.

  23. def zipwith[L, R, O](f: (L, R) ⇒ O)(lin: channel.?[L], rin: channel.?[R], out: channel.![O]): PROC

    Repeatedly input pairs of values (l, r) from lin, and rin and send f(l, r) to out.

Inherited from AnyRef

Inherited from Any

Ungrouped