28 std::cout <<
"[thread_reader ID:" << std::this_thread::get_id()
29 <<
"] Started." << std::endl;
34 read_pipe.
Read(&len,
sizeof(len));
35 read_pipe.
Read(buf, len);
37 cout <<
"RX: " << buf << endl;
43 #if !defined(HAS_BROKEN_CLANG_STD_VISIT)
44 auto doprint = [](
auto& pose) { cout <<
"RX pose: " << pose << endl; };
47 std::visit(doprint, var);
49 std::visit(doprint, var);
51 std::cout <<
"Code disabled for clang due to variant bug. See: "
52 "https://stackoverflow.com/a/46507150/1631514\n";
55 printf(
"[thread_reader] Finished.\n");
57 catch (
const std::exception& e)
59 cerr << e.what() << endl;
67 std::cout <<
"[thread_writer ID:" << std::this_thread::get_id()
68 <<
"] Started." << std::endl;
71 const char* str =
"Hello world!";
72 size_t len = strlen(str);
73 write_pipe.
Write(&len,
sizeof(len));
74 write_pipe.
Write(str, len);
80 #if !defined(HAS_BROKEN_CLANG_STD_VISIT)
81 std::variant<mrpt::poses::CPose3D, mrpt::poses::CPose2D> var1(
83 std::variant<mrpt::poses::CPose3D, mrpt::poses::CPose2D> var2(
86 arch.WriteVariant(var1);
87 arch.WriteVariant(var2);
89 printf(
"[thread_writer] Finished.\n");
91 catch (
const std::exception& e)
93 cerr << e.what() << endl;
103 std::unique_ptr<CPipeReadEndPoint> read_pipe;
104 std::unique_ptr<CPipeWriteEndPoint> write_pipe;
106 CPipe::createPipe(read_pipe, write_pipe);
112 using namespace std::chrono_literals;
113 std::this_thread::sleep_for(10ms);
133 catch (
const std::exception& e)
140 printf(
"Untyped exception!!");