SourceForge.net Logo

xSTreamC default filter templates

The xSTreamC compiler provides a default set of predefined filters that can be freely used in code. Additionally these same filters, will be leveraged for the default definition of a splitter, joiner or other implicit filter instances

Splitters / Joiners

roundrobin()

This filter performs a roundrobin selection of all input and output queues. For example, a filter with 2 inputs a & b and 3 output A, B & C would work in the following way:

input queuesoutput queues
54321a
131211b
roundrobin()
A4121
B311
C132

:!: It can stop asymetrically, like in the example above, if not enough data (for input queues) or space left (for output queues) is available . (A symetrical implementation wouldn’t have pushed the ‘4’ on the ouput queue A).

see the implementation of roundrobin splitter/joiner.

duplicate()

This filter clones data from the input queue by pushing it ontp all output queues

input queueoutput queues
54321a
duplicate()
A54321
B54321
C54321

select_split(int out_queue)

This filter selects an output queue. The remaining ones will not receive data.

It takes as argument the selected output queue.

input queueoutput queues
54321a
select_split(1)
A
B54321
C

select_join(int in_queue)

Symetrically, this one selects one input queue for data input

It takes as argument the selected input queue.

input queueoutput queues
54321a
131211b
select_join(0)
A54321

Other library filters

id()

This is the most simple filter you can think of ! It just reads from an input queue and sends the same data onto the output queue.

Example of code

Here is one example, using template syntax place holders...

filter  roundrobin()
{
  int i,j;
  init {
    i=0;
    j=0;
  }
  work {
    generic data;
    data = pop(i);
    push(data, j);
 
    j++;
    if(j == @NB_QUEUES_OUT@)
    {
      j=0;
      i++;
      i %= @NB_QUEUES_IN@;
    }
    peek(0, i); /* Peek next in queue */
  }
}