Initial prototype of asynchronous detection. DMI information broken
This commit is contained in:
parent
5270b46e31
commit
7898e9b95d
5 changed files with 87 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
#include "RGBController.h"
|
||||
|
|
@ -10,6 +11,8 @@
|
|||
typedef std::function<void(std::vector<RGBController*>&)> DeviceDetectorFunction;
|
||||
typedef std::function<void(std::vector<i2c_smbus_interface*>&, std::vector<RGBController*>&)> I2CDeviceDetectorFunction;
|
||||
|
||||
typedef void (*ResourceManagerCallback)(void *);
|
||||
|
||||
class ResourceManager
|
||||
{
|
||||
public:
|
||||
|
|
@ -27,8 +30,14 @@ public:
|
|||
void RegisterDeviceDetector (DeviceDetectorFunction detector);
|
||||
void RegisterI2CDeviceDetector (I2CDeviceDetectorFunction detector);
|
||||
|
||||
void RegisterDeviceListChangeCallback(ResourceManagerCallback new_callback, void * new_callback_arg);
|
||||
|
||||
void DeviceListChanged();
|
||||
|
||||
void DetectDevices();
|
||||
|
||||
void DetectDevicesThreadFunction();
|
||||
|
||||
private:
|
||||
static std::unique_ptr<ResourceManager> instance;
|
||||
|
||||
|
|
@ -36,4 +45,10 @@ private:
|
|||
std::vector<RGBController*> rgb_controllers;
|
||||
std::vector<DeviceDetectorFunction> device_detectors;
|
||||
std::vector<I2CDeviceDetectorFunction> i2c_device_detectors;
|
||||
|
||||
std::thread * DetectDevicesThread;
|
||||
|
||||
std::mutex DeviceListChangeMutex;
|
||||
std::vector<ResourceManagerCallback> DeviceListChangeCallbacks;
|
||||
std::vector<void *> DeviceListChangeCallbackArgs;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue