From 63419b095f2e4c0763393a4fb81694de67a3a97b Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Wed, 17 Feb 2016 12:18:28 +0100 Subject: [PATCH] examples: adapted dataflow example for new semantics --- doc/examples/dataflow/dataflow_producer-snippet.h | 12 ++++++++---- doc/examples/dataflow/dataflow_source_function-snippet.h | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) 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; + } } -- libgit2 0.26.0