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:
37
src/logid/util/mutex_queue.h
Normal file
37
src/logid/util/mutex_queue.h
Normal 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
|
Reference in New Issue
Block a user