dataflow_producer-snippet.h 264 Bytes
Newer Older
1 2 3
template <typename T>
class Producer {
 public:
4 5
  explicit Producer(int seed) : seed_(seed), count_(4) {}
  bool Run(T& x) {
6 7
    // produce a new value x
    x = SimpleRand(seed_);
8 9
    count_--;
    return count_ >= 0;
10 11 12 13
  }

 private:
  int seed_;
14
  int count_;
15
};