示例#1
0
  public void connectGraph() {
    // make sure I have some elements - not sure what to do otherwise
    assert !streamElements.isEmpty();

    // go through the list and connect it together:
    ListIterator<Stream> childIter;
    childIter = (ListIterator<Stream>) streamElements.iterator();
    Stream source = null;

    while (childIter.hasNext()) {
      // advance the iterator:
      Stream sink = childIter.next();
      assert sink != null;

      // setup the sink itself
      sink.setupOperator();

      if (source != null && source.getOutputChannel() != null) {
        // create and connect a pass filter
        ChannelConnectFilter connect = new ChannelConnectFilter();
        Channel in = source.getOutputChannel();
        Channel out = sink.getInputChannel();
        connect.useChannels(in, out);
        connect.setupOperator();
      }
      source = sink;
    }

    // set myself up with proper input and output
    {
      inputChannel = streamElements.getFirst().getInputChannel();
      outputChannel = streamElements.getLast().getOutputChannel();
    }
  }
示例#2
0
  void setupBufferLengths(Scheduler buffers) {
    ListIterator<Stream> childIter;
    childIter = (ListIterator<Stream>) streamElements.iterator();
    Stream source = null;
    Stream sink = null;

    // go through all the children
    while (childIter.hasNext()) {
      // advance the iterator:
      Stream child = childIter.next();
      assert child != null;
      child.setupBufferLengths(buffers);

      source = sink;
      sink = child;

      if (source != null) {
        assert sink != null;

        int buffSize = buffers.getBufferSizeBetween(new Iterator(source), new Iterator(sink));
        assert buffSize != 0;

        StreamIt.totalBuffer += buffSize;

        source.getOutputChannel().makePassThrough();
        sink.getInputChannel().setChannelSize(buffSize);
      }
    }
  }