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

Push events into a processor of input arity 2. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Push events into a processor of input arity 2.

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

Processor graph

The expected output of this program is:

0,2,4,6,8,10,12,14,
See also
PipingUnaryPush
Author
Sylvain Hallé Easy

Definition at line 40 of file BinaryPush.java.

Member Function Documentation

◆ main()

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

We create an instance of the adder processor

Definition at line 42 of file BinaryPush.java.

43  {
44  /// We create an instance of the adder processor
45  Adder add = new Adder();
46 
47  // We then create a Print processor, which prints its input
48  // to the console
49  Print print = new Print().setSeparator("\n");
50 
51  // We connect the output of add to the input of print
52  Connector.connect(add, print);
53 
54  // We now get a hold of the adder's pushables. Since add is of input
55  // arity 2, it has two such pushables, numbered 0 and 1. Notice how
56  // we use a different version of getPushableInput, which takes an
57  // integer as an argument
58  Pushable p0 = add.getPushableInput(0);
59  Pushable p1 = add.getPushableInput(1);
60  ///
61 
62  //* Let us push an event into p0. Nothing is printed, as the Adder
63  // requires one event on each of its input pipes to do something.
64  p0.push(3);
65  System.out.println("This is the first printed line");
66 
67  // Let us push an event into p1. Since an event was ready to be
68  // consumed at p0, adder can proceed with the addition and push its
69  // result to print.
70  p1.push(1);
71 
72  // We now push two events in a row to p1. As above, nothing is printed
73  p1.push(4);
74  p1.push(1);
75  System.out.println("This is the third printed line");
76 
77  // We push two events to p0. Since events in p1 are ready to be
78  // consumed, each push on p0 triggers the evaluation of a new addition
79  p0.push(5);
80  p0.push(9);
81  //*
82  }

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