Rearrange the try-catch in the thread handlers

It's a bit clearer this way. I would prefer using jthreads here, but we
would still need this try-catch block since there's no way to cancel
synchronous Boost.Asio socket operations other than closing the socket.
This commit is contained in:
Robbert van der Helm
2020-06-20 15:47:30 +02:00
parent c5f8a3a1b2
commit f5f6f04016
2 changed files with 30 additions and 25 deletions
+6 -5
View File
@@ -132,8 +132,8 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
// instead of asynchronous IO since communication has to be handled in
// lockstep anyway
host_callback_handler = std::thread([&]() {
try {
while (true) {
while (true) {
try {
// TODO: Think of a nicer way to structure this and the similar
// handler in `Vst2Bridge::handle_dispatch_midi_events`
receive_event(
@@ -159,10 +159,11 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
&plugin, host_callback_function)(event);
}
});
} catch (const boost::system::system_error&) {
// This happens when the sockets got closed because the plugin
// is being shut down
break;
}
} catch (const boost::system::system_error&) {
// This happens when the sockets got closed because the plugin
// is being shut down
}
});