Code Examples
A repository of 155 code examples for BeepBeep
basic.PipingUnary Class Reference

Pipe processors together using the Connector object. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Pipe processors together using the Connector object.

The chain of processors in this example can be represented graphically as:

Processor graph
See also
PipingBinary
Author
Sylvain Hallé Easy

Definition at line 36 of file PipingUnary.java.

Member Function Documentation

◆ main()

static void basic.PipingUnary.main ( String []  args)
static

Create a source of arbitrary numbers

Definition at line 38 of file PipingUnary.java.

39  {
40  /// Create a source of arbitrary numbers
41  QueueSource source = new QueueSource();
42  source.setEvents(1, 2, 3, 4, 5, 6);
43 
44  /* Create an instance of the Doubler processor (which is defined just
45  * below in this file. */
46  Doubler doubler = new Doubler();
47 
48  /* We now want to connect the output of source to the input of doubler.
49  * This connection is done by using static method connect() of the
50  * Connector object. Here, source has only one output stream, and
51  * doubler has only one input stream. Therefore, we can simply call
52  * connect() by giving the "upstream" processor first, and the
53  * "downstream" processor second. The Connector will know that it needs
54  * to connect the (only) output of source to the (only) input of
55  * doubler. */
56  Connector.connect(source, doubler);
57 
58  /* Let us now print what we receive by pulling on the output of
59  * doubler. */
60  Pullable p = doubler.getPullableOutput();
61  for (int i = 0; i < 8; i++)
62  {
63  int x = (Integer) p.pull();
64  System.out.println("The event is: " + x);
65  // Sleep a little so you have time to read
66  UtilityMethods.pause(1000);
67  }
68  ///
69  }

The documentation for this class was generated from the following file: