compatybility with old C++ on macos
This commit is contained in:
parent
01e0693031
commit
0bb1f22379
@ -167,7 +167,8 @@ struct Runner
|
||||
midi::Serial_Midi midi;
|
||||
Interpreter interpreter;
|
||||
std::shared_ptr<serialport::State> serial_state;
|
||||
std::optional<std::jthread> serial_event_loop;
|
||||
std::thread serial_event_loop;
|
||||
std::atomic<bool> serial_event_loop_stop = false;
|
||||
|
||||
/// Setup interpreter and midi connection with given port
|
||||
explicit Runner(std::optional<unsigned> output_port)
|
||||
@ -183,8 +184,8 @@ struct Runner
|
||||
midi.serialport = serial_state;
|
||||
serialport::initialize();
|
||||
|
||||
serial_event_loop = std::jthread([this](std::stop_token token) mutable{
|
||||
serialport::event_loop(token, *serial_state);
|
||||
serial_event_loop = std::thread([this]() mutable {
|
||||
serialport::event_loop(serial_event_loop_stop, *serial_state);
|
||||
});
|
||||
|
||||
interpreter.midi_connection = &midi;
|
||||
@ -209,6 +210,13 @@ struct Runner
|
||||
Runner& operator=(Runner const&) = delete;
|
||||
Runner& operator=(Runner &&) = delete;
|
||||
|
||||
~Runner() {
|
||||
serial_event_loop_stop = true;
|
||||
if (serial_event_loop.joinable()) {
|
||||
serial_event_loop.join();
|
||||
}
|
||||
}
|
||||
|
||||
/// Consider given input file as new definition of parametless function
|
||||
///
|
||||
/// Useful for deffering execution of files to the point when all configuration of midi devices
|
||||
|
@ -38,9 +38,9 @@ namespace serialport{
|
||||
return 8;
|
||||
}
|
||||
|
||||
void event_loop(std::stop_token token, State &state)
|
||||
void event_loop(std::atomic<bool> &stop, State &state)
|
||||
{
|
||||
while(!token.stop_requested()){
|
||||
while(!stop){
|
||||
try {
|
||||
/// Search for the right device
|
||||
auto const ports = serial::list_ports();
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <serial/serial.h>
|
||||
#include <stop_token>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
@ -26,7 +25,7 @@ namespace serialport{
|
||||
};
|
||||
|
||||
void initialize();
|
||||
void event_loop(std::stop_token token, State &state);
|
||||
void event_loop(std::atomic<bool> &stop, State &state);
|
||||
std::uint8_t get_byte();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user