I was wondering why a lot of the example code is more C code than C++ code. For instance, in the reference manual, cstdio is used instead of iostream, or for the tacheon demo, the whole code is in fact C code (no object, no class, ...).
Hi Matthieu, I don't know a definitive answer to that question, but can speculate. First, why not? A programmer more comfortable with C can still make use of TBB, sometimes without stepping too far into the C++ zone. That could be the case for some of the examples. In other cases, I would bet that an existing serial or parallel code was implemented in C and then parallelized with TBB later. Hopefully someone who knows the history of the TBB examples can share their insight.
Well, I'm not a TBB developer, but the answer seems very simple - the example should be simple and dense. That's why using object-oriented programming in examples, with defining assignments, copy constructors, other constructors, etc., etc. is a bit anti-climactic. Which does not mean, it is not nice in actual projects.C and C++ are quite similar, but for plain C is much more dense for short and simple programs.
Since we're in the realm of speculation, I'll speculate that the codes as originally required were probably C sources. Regardless of this provenance, they are now all C++ codes requiring a C++ compiler to handle at least their TBB-interface sections. Our purpose after all is to exemplify parallel coding practices with TBB rather than object-oriented programming practices. Maybe someday we can direct some overeager intern with time on their hands to "objectify" the plain C code, but I suspect that this would be pretty low on our priority list.
I haven't tried yet, but from the specification it seems fairly straightforward. This way, you pass the reference to the container directly through the iterators instead of indirectly to the Body, where it would have been combined with the blocked_range values only in the application operator. Did that not work for you? Examples are always nice to have, of course.
I don't disagree at all about having examples that lower the learning curve. I guess the issue with the first example is that TBB could use a tbb::make_blocked_range etc., like C++'s std::make_pair, to avoid having to be specific about the template parameters? If the second is about blocked_range(container,100), there's no substitute for looking at the documentation once in a while. :-)