degskiOn 16 May 2018 at 05:11, Surya Kiran Gullapalli via Boost-users <boost-users@lists.boost.org> wrote:Hi,I'm trying to read outputs/logs from different processes and display them in a GUI. The processes will be running for long time and produce huge output. I'm planning to stream the output from those processes and display them according to my needs. All the while allow my gui application to take user inputs and perform other actions.What I've done here is, from main thread launch two threads for each process. One for launching the process and another for reading output from the process.This is the solution I've come up thus far.// Process Classclass MyProcess {namespace bp = boost::process;boost::asio::io_service mService; // member variable of the classbp::ipstream mStream // member variable of the classstd::thread mProcessThread, mReaderThread // member variables of the class.public void launch();};voidMyProcess::launch(){mReaderThread = std::thread([&](){std::string line;while(getline(mStream, line)) {std::cout << line << std::endl;}});mProcessThread = std::thread([&]() {auto c = boost::child ("/path/of/executable", bp::std_out > mStream, mService);mService.run();mStream.pipe().close();}}// Main Gui classclass MyGui{MyProcess process;void launchProcess();}MyGui::launchProcess(){process.launch();doSomethingElse();}The program is working as expected so far. But I'm not sure if this is the correct solution. Please let me know if there's any alternative/better/correct solutionThere is a place to put/ask this kind of questions: https://codereview.stackexchange.com/ --"If something cannot go on forever, it will stop" - Herbert Stein
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost- users