Code Examples
A repository of 155 code examples for BeepBeep
StatefulDuplication.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2018 Sylvain HallĂ©
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package customprocessors;
19 
20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.Pullable;
22 import ca.uqac.lif.cep.tmf.QueueSource;
23 
24 public class StatefulDuplication
25 {
26 
27  public static void main(String[] args)
28  {
29  System.out.println("--- Version one ---");
30  {
31  ///
32  QueueSource src1 = new QueueSource();
33  src1.setEvents(2, 1);
34  Stuttering s1 = new Stuttering();
35  Connector.connect(src1, s1);
36  Pullable p1 = s1.getPullableOutput();
37  System.out.println("Call to pull on p1: " + p1.pull());
38  ///
39  //*
40  QueueSource src2 = new QueueSource();
41  src2.setEvents(3, 1);
42  Stuttering s2 = s1.duplicate(true);
43  Connector.connect(src2, s2);
44  Pullable p2 = s2.getPullableOutput();
45  System.out.println("Call to pull on p2: " + p2.pull());
46  //*
47  }
48  System.out.println("\n --- Version two ---");
49  {
50  //!
51  QueueSource src1 = new QueueSource();
52  src1.setEvents(2, 1);
53  StutteringCopy s1 = new StutteringCopy();
54  Connector.connect(src1, s1);
55  Pullable p1 = s1.getPullableOutput();
56  System.out.println("Call to pull on p1: " + p1.pull());
57  QueueSource src2 = new QueueSource();
58  src2.setEvents(3, 1);
59  StutteringCopy s2 = s1.duplicate(true);
60  Connector.connect(src2, s2);
61  Pullable p2 = s2.getPullableOutput();
62  System.out.println("Call to pull on p2: " + p2.pull());
63  //!
64  }
65  }
66 }