diff --git a/doc/examples/dataflow/dataflow_producer-snippet.h b/doc/examples/dataflow/dataflow_producer-snippet.h index ffaf79e..f76065c 100644 --- a/doc/examples/dataflow/dataflow_producer-snippet.h +++ b/doc/examples/dataflow/dataflow_producer-snippet.h @@ -3,10 +3,14 @@ class Producer { public: explicit Producer(int seed) : seed_(seed), count_(4) {} bool Run(T& x) { - // produce a new value x - x = SimpleRand(seed_); - count_--; - return count_ >= 0; + if (count_ >= 0) { + // produce a new value x + x = SimpleRand(seed_); + count_--; + return true; + } else { + return false; + } } private: diff --git a/doc/examples/dataflow/dataflow_source_function-snippet.h b/doc/examples/dataflow/dataflow_source_function-snippet.h index 6c1cdea..1afc660 100644 --- a/doc/examples/dataflow/dataflow_source_function-snippet.h +++ b/doc/examples/dataflow/dataflow_source_function-snippet.h @@ -1,4 +1,8 @@ bool SourceFunction(std::string & str) { - std::getline(file, str); - return !file.eof(); + if (!file.eof()) { + std::getline(file, str); + return true; + } else { + return false; + } }