main()
{
Chain1 generator;
Chain2 preprocessor;
Chain3 processor;
// to communicate to the parent for data transfer
processsor.makeChild(&generator);
processor.makeChild(&preprocessor);
// initialize the threads
generator.init();
preprocessor.init();
processor.init();
// join the threads
generator.start();
preprocessor.start(); // issue here hangs up here trying to join
processor.start();
}
class Chain1 //or Chain2 or Chain3...
{
init()
{
// stored as a class member
chain_thread = std::thread(&Chain1::Dofunction, this); // or std::thread(&Chain2::Dofunction, this); // or std::thread(&Chain3::Dofunction, this);
}
start()
{
chain_thread.join();
}
Dofunction()
{
while(true)
{
//... different for each Chain1, Chain2, Chain3
}
}