The graph examples don't answer questions about what happens if inputs arrive out of order. The initial graph example logging, such as in fig_3_05 is also easier to understand if tbb::flow::serial is used instead of unlimited for the nodes. I'm adding random 1 to 10msec work delays as the inputs are applied to help my understanding of the issues, calling a spin_msec function to insert the delays.
`
void spin_msecs( int msecs) {
tbb::tick_count t0 = tbb::tick_count::now();
while ((tbb::tick_count::now() - t0).seconds()*1000.0 < msecs);
}
`
I'm calling with random generation
`
std::minstd_rand simple_rand;
simple_rand.seed(42);
`
then calling with
`
spin_msecs(simple_rand()%10+1);
`
I'm attaching my modified fig_3_05.cpp code as an example.
fig_3_05.zip
Also, after uploading this, I added a log after the step 4, prior to the wait_for_all to understand that the try_put calls are not blocking.
`
{
std::stringstream ss;
ss << "try_puts done. proceeding to wait_for_all" << std::endl;
cout_locked(ss.str());
}
`
The graph examples don't answer questions about what happens if inputs arrive out of order. The initial graph example logging, such as in fig_3_05 is also easier to understand if tbb::flow::serial is used instead of unlimited for the nodes. I'm adding random 1 to 10msec work delays as the inputs are applied to help my understanding of the issues, calling a spin_msec function to insert the delays.
`
void spin_msecs( int msecs) {
}
`
I'm calling with random generation
`
std::minstd_rand simple_rand;
simple_rand.seed(42);
`
then calling with
`
spin_msecs(simple_rand()%10+1);
`
I'm attaching my modified fig_3_05.cpp code as an example.
fig_3_05.zip
Also, after uploading this, I added a log after the step 4, prior to the wait_for_all to understand that the try_put calls are not blocking.
`
{
std::stringstream ss;
ss << "try_puts done. proceeding to wait_for_all" << std::endl;
cout_locked(ss.str());
}
`