277{
278 using namespace std::string_literals;
279 try {
280 if (!lr_ipc_shared->thread_should_exit_.load(std::memory_order_acquire)) {
281 asio::async_read_until(lr_ipc_shared->socket_, lr_ipc_shared->streambuf_, '\n',
282 [lr_ipc_shared](const asio::error_code& error,
283 const std::size_t bytes_transferred) mutable {
284 if (!error) [[likely]] {
285 if (bytes_transferred == 0) [[unlikely]] { std::this_thread::sleep_for(kEmptyWait); }
286 else {
287 auto& buf {lr_ipc_shared->streambuf_};
288 std::string command {buffers_begin(buf.data()),
289 buffers_begin(buf.data()) + gsl::narrow<std::ptrdiff_t>(bytes_transferred)};
290 if (command == "TerminateApplication 1\n"s) {
291 lr_ipc_shared->thread_should_exit_.store(true, std::memory_order_release);
292 }
293 lr_ipc_shared->line_.push(std::move(command));
294 buf.consume(bytes_transferred);
295 }
296 Read(std::move(lr_ipc_shared));
297 }
298 else {
299 rsj::Log(fmt::format(FMT_STRING("LR_IPC_In Read error: {}."), error.message()),
300 std::source_location::current());
301
302 if (error == asio::error::misc_errors::eof) {
303 juce::JUCEApplication::getInstance()->systemRequestedQuit();
304 }
305 }
306 });
307 }
308 }
309 catch (const std::exception& e) {
311 throw;
312 }
313}
void ExceptionResponse(gsl::czstring id, gsl::czstring fu, const std::exception &e) noexcept