Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boost::asio::io_context ctx;
- class Pipe
- {
- private:
- boost::process::async_pipe pipe;
- std::string read_buf;
- public:
- Pipe() : pipe(ctx, cfg::PipeName)
- {
- fs.open("tester.txt", std::ios_base::out);
- }
- void Run()
- {
- fs << "Run launch" << std::endl;
- boost::asio::async_read_until(
- pipe,
- boost::asio::dynamic_buffer(read_buf),
- '\n',
- [this](const boost::system::error_code& error, size_t bytes)
- {
- fs << "Handler" << std::endl;
- if (error)
- {
- fs << error << std::endl;
- }
- if (!read_buf.empty())
- {
- fs << "Readed str: " << read_buf << std::endl;
- }
- else
- {
- fs << "Empty buf!" << std::endl;
- }
- boost::asio::post(ctx, boost::bind(&Pipe::Run, this));
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement