Make sure messages can't get out of order

This commit is contained in:
Robbert van der Helm
2020-03-23 22:33:28 +01:00
parent 5d1051a00c
commit d2be82285a
+5 -6
View File
@@ -146,15 +146,14 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
const Event event{opcode, index, value, option, payload.value()}; const Event event{opcode, index, value, option, payload.value()};
// Prevent two threads from writing over the socket at the same time. This // Prevent two threads from writing over the socket at the same time and
// should not be needed, but for instance Bitwig's plugin bridge will // messages getting out of order. This is needed because we can't prevent
// sometimes repeatedly send events from an off thread that may overlap with // the plugin or the host from calling `dispatch()` or `audioMaster()` from
// other `dispatch()` calls. // multiple threads.
write_semaphore.lock(); write_semaphore.lock();
write_object(socket, event); write_object(socket, event);
write_semaphore.unlock();
const auto response = read_object<EventResult>(socket); const auto response = read_object<EventResult>(socket);
write_semaphore.unlock();
if (logging.has_value()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value(); auto [logger, is_dispatch] = logging.value();