void update_lights(const std::map<LightKey, uint8_t> &active_lights)
{
- std::lock_guard<std::mutex> lock(mu);
+ std::lock_guard<std::recursive_mutex> lock(mu);
update_lights_lock_held(active_lights);
}
std::atomic<bool> should_quit{false};
int should_quit_fd;
- mutable std::mutex mu;
- MIDIReceiver *receiver; // Under <mu>.
+ // Recursive because the MIDI receiver may update_lights() back while we are sending it stuff.
+ // TODO: Do we need this anymore after receiver is not under the lock?
+ mutable std::recursive_mutex mu;
+ MIDIReceiver *receiver; // _Not_ under <mu>; everything on it should be thread-safe.
std::thread midi_thread;
std::map<LightKey, uint8_t> current_light_status; // Keyed by note number. Under <mu>.