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

Pull events from the QueueSource processor. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Pull events from the QueueSource processor.

Graphically, the queue source is represented as follows:

Processor graph

Since it is a source, it has no input streams. We represent in a rectangle the queue of events that the source will dispense.

Author
Sylvain Hallé Easy

Definition at line 35 of file QueueSourceUsage.java.

Member Function Documentation

◆ main()

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

Create an empty queue source

Definition at line 37 of file QueueSourceUsage.java.

38  {
39  /// Create an empty queue source
40  QueueSource source = new QueueSource();
41  // Tell the source what events to output by giving it an array;
42  // in this case, we output the first powers of 2
43  source.setEvents(1, 2, 4, 8, 16, 32);
44  // Get a pullable to the source
45  Pullable p = source.getPullableOutput();
46  // Pull 8 events from the source. The queue source loops through
47  // its array of events; hence after reaching the last (32), it
48  // will restart from the beginning of its list.
49  for (int i = 0; i < 8; i++)
50  {
51  // Method pull() returns an Object, hence we must manually cast
52  // it as an integer (this is indeed what we get)
53  int x = (Integer) p.pull();
54  System.out.println("The event is: " + x);
55  }
56  ///
57  }

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