Add mutex for events on Receiver
This commit is contained in:
		@@ -31,6 +31,7 @@ Receiver::Receiver(std::string path) : dj::ReceiverMonitor(path), _path (path)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Receiver::addDevice(hidpp::DeviceConnectionEvent event)
 | 
					void Receiver::addDevice(hidpp::DeviceConnectionEvent event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    std::unique_lock<std::mutex> lock(_devices_change);
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        auto dev = _devices.find(event.index);
 | 
					        auto dev = _devices.find(event.index);
 | 
				
			||||||
        if(dev != _devices.end()) {
 | 
					        if(dev != _devices.end()) {
 | 
				
			||||||
@@ -71,5 +72,6 @@ void Receiver::addDevice(hidpp::DeviceConnectionEvent event)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Receiver::removeDevice(hidpp::DeviceIndex index)
 | 
					void Receiver::removeDevice(hidpp::DeviceIndex index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    std::unique_lock<std::mutex> lock(_devices_change);
 | 
				
			||||||
    _devices.erase(index);
 | 
					    _devices.erase(index);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -34,6 +34,7 @@ namespace logid
 | 
				
			|||||||
        void addDevice(backend::hidpp::DeviceConnectionEvent event) override;
 | 
					        void addDevice(backend::hidpp::DeviceConnectionEvent event) override;
 | 
				
			||||||
        void removeDevice(backend::hidpp::DeviceIndex index) override;
 | 
					        void removeDevice(backend::hidpp::DeviceIndex index) override;
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
 | 
					        std::mutex _devices_change;
 | 
				
			||||||
        std::map<backend::hidpp::DeviceIndex, std::shared_ptr<Device>> _devices;
 | 
					        std::map<backend::hidpp::DeviceIndex, std::shared_ptr<Device>> _devices;
 | 
				
			||||||
        std::string _path;
 | 
					        std::string _path;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user