Monitor all HID++ reports on wireless device 1

Again, many things were done in this commit such as implementing an
I/O queue, a mutex_queue, and implementing the hidpp::Report class.

I'm expecting commits to be like this until I can get a clean
codebase for the backend.
This commit is contained in:
pixl
2020-06-17 02:43:53 -04:00
parent 1de722b935
commit 6b895b3015
14 changed files with 442 additions and 55 deletions

View File

@@ -0,0 +1,37 @@
#ifndef MUTEX_QUEUE_H
#define MUTEX_QUEUE_H
#include <queue>
#include <mutex>
template<typename data>
class mutex_queue
{
public:
mutex_queue<data>() = default;
bool empty()
{
std::lock_guard<std::mutex> lock(_mutex);
return _queue.empty();
}
data& front()
{
std::lock_guard<std::mutex> lock(_mutex);
return _queue.front();
}
void push(const data& _data)
{
std::lock_guard<std::mutex> lock(_mutex);
_queue.push(_data);
}
void pop()
{
std::lock_guard<std::mutex> lock(_mutex);
_queue.pop();
}
private:
std::queue<data> _queue;
std::mutex _mutex;
};
#endif //MUTEX_QUEUE_H