In Dataflow.Signals, we have signal producers and signal consumers. But note that the flow of data can go in both directions. The caller (signal producer) could be considered the data producer if it supplies data in the provided arguments. On the other hand, the callee (signal consumer) could be considered the data producer if it returns data either in the return value or through one of the parameters.

Most of the examples in this documentation focus on the former case, where the signal producer is the data producer (this could also be called a push-based network). Here we will present an example of the latter case, where the signal consumer is the data producer (i.e., a pull-based network).

The following component requests a value through a signal, and returns twice the value:

class PullDoubler : public signals::filter<PullDoubler, float ()>
{
public:
    float operator()()
    {
        return 2*out();
    }
};

This class can be connected using the usual operators:

signals::storage<void(float)> generator(1.0f);
PullDoubler doubler;

// ---Connect the dataflow network ---------------------
//
//     ,---------.    
//     | doubler | <---------------. 
//     `---------'                 |
//                      ,-(value_at_slot<0>)-.
//                      |      generator     |
//                      `--------------------'
//
// -----------------------------------------------------

doubler >>= generator.value_at_slot<0>();
    
BOOST_CHECK(doubler() == 2.0f);

The value_at_slot<0> member function returns a boost::function pointing to the at<0> member function of storage. Because we initalized generator with a value of 1.0f, that is what at<0> will return. doubler will double that value and return 2.0f.