Add workqueue system

This commit is contained in:
pixl
2020-07-10 03:16:51 -04:00
parent 02d361b541
commit 1f3fa53721
15 changed files with 529 additions and 15 deletions

View File

@@ -17,7 +17,7 @@
*/
#include "ReceiverMonitor.h"
#include "../../util/thread.h"
#include "../../util/task.h"
#include "../../util/log.h"
#include <utility>
@@ -57,7 +57,7 @@ void ReceiverMonitor::run()
/* Running in a new thread prevents deadlocks since the
* receiver may be enumerating.
*/
thread::spawn({[this, report]() {
task::spawn({[this, report]() {
if (report.subId() == Receiver::DeviceConnection)
this->addDevice(this->_receiver->deviceConnectionEvent
(report));

View File

@@ -17,7 +17,7 @@
*/
#include "DeviceMonitor.h"
#include "../../util/thread.h"
#include "../../util/task.h"
#include "../../util/log.h"
#include <thread>
@@ -98,14 +98,14 @@ void DeviceMonitor::run()
std::string devnode = udev_device_get_devnode(device);
if (action == "add")
thread::spawn([this, name=devnode]() {
task::spawn([this, name=devnode]() {
this->addDevice(name);
}, [name=devnode](std::exception& e){
logPrintf(WARN, "Error adding device %s: %s",
name.c_str(), e.what());
});
else if (action == "remove")
thread::spawn([this, name=devnode]() {
task::spawn([this, name=devnode]() {
this->removeDevice(name);
}, [name=devnode](std::exception& e){
logPrintf(WARN, "Error removing device %s: %s",
@@ -157,7 +157,7 @@ void DeviceMonitor::enumerate()
std::string devnode = udev_device_get_devnode(device);
udev_device_unref(device);
thread::spawn([this, name=devnode]() {
task::spawn([this, name=devnode]() {
this->addDevice(name);
}, [name=devnode](std::exception& e){
logPrintf(ERROR, "Error adding device %s: %s",