Skip to content

Commit dbe24f9

Browse files
committed
Phase out workqueue
1 parent 1dd6dbf commit dbe24f9

34 files changed

Lines changed: 128 additions & 624 deletions

src/logid/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ add_executable(logid
6464
backend/hidpp20/features/WirelessDeviceStatus.cpp
6565
backend/hidpp20/features/ThumbWheel.cpp
6666
backend/dj/Report.cpp
67-
util/mutex_queue.h
68-
util/workqueue.cpp
69-
util/worker_thread.cpp
70-
util/task.cpp
7167
util/thread.cpp
68+
util/task.cpp
7269
util/ExceptionHandler.cpp)
7370

7471
set_target_properties(logid PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

src/logid/Device.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ std::shared_ptr<Device> Device::make(
9898
Device::Device(std::string path, backend::hidpp::DeviceIndex index,
9999
std::shared_ptr<DeviceManager> manager) :
100100
_hidpp20 (path, index,
101-
manager->config()->io_timeout.value_or(defaults::io_timeout),
102-
manager->workQueue()),
101+
manager->config()->io_timeout.value_or(defaults::io_timeout)),
103102
_path (std::move(path)), _index (index),
104103
_config (_getConfig(manager, _hidpp20.name())),
105104
_receiver (nullptr),
@@ -213,19 +212,6 @@ void Device::reset()
213212
"available.", _path.c_str(), _index);
214213
}
215214

216-
std::shared_ptr<workqueue> Device::workQueue() const
217-
{
218-
if(auto manager = _manager.lock()) {
219-
return manager->workQueue();
220-
} else {
221-
logPrintf(ERROR, "Device manager lost");
222-
logPrintf(ERROR,
223-
"Fatal error occurred, file a bug report,"
224-
" the program will now exit.");
225-
std::terminate();
226-
}
227-
}
228-
229215
std::shared_ptr<InputDevice> Device::virtualInput() const
230216
{
231217
if(auto manager = _manager.lock()) {

src/logid/Device.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ namespace logid
8282

8383
void reset();
8484

85-
[[nodiscard]] std::shared_ptr<workqueue> workQueue() const;
8685
[[nodiscard]] std::shared_ptr<InputDevice> virtualInput() const;
8786
[[nodiscard]] std::shared_ptr<ipcgull::node> ipcNode() const;
8887

src/logid/DeviceManager.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "DeviceManager.h"
2525
#include "Receiver.h"
2626
#include "util/log.h"
27-
#include "util/workqueue.h"
2827
#include "backend/hidpp10/Error.h"
2928
#include "backend/Error.h"
3029

@@ -44,7 +43,7 @@ namespace logid {
4443
DeviceManager::DeviceManager(std::shared_ptr<Configuration> config,
4544
std::shared_ptr<InputDevice> virtual_input,
4645
std::shared_ptr<ipcgull::server> server) :
47-
backend::raw::DeviceMonitor(config->workers.value_or(defaults::worker_count)),
46+
backend::raw::DeviceMonitor(),
4847
_server (std::move(server)), _config (std::move(config)),
4948
_virtual_input (std::move(virtual_input)),
5049
_root_node (ipcgull::node::make_root("")),
@@ -96,8 +95,7 @@ void DeviceManager::addDevice(std::string path)
9695
// Check if device is ignored before continuing
9796
{
9897
raw::RawDevice raw_dev(
99-
path,config()->io_timeout.value_or(defaults::io_timeout),
100-
workQueue());
98+
path,config()->io_timeout.value_or(defaults::io_timeout));
10199
if(config()->ignore.has_value() &&
102100
config()->ignore.value().contains(raw_dev.productId())) {
103101
logPrintf(DEBUG, "%s: Device 0x%04x ignored.",
@@ -109,8 +107,7 @@ void DeviceManager::addDevice(std::string path)
109107
try {
110108
hidpp::Device device(
111109
path, hidpp::DefaultDevice,
112-
config()->io_timeout.value_or(defaults::io_timeout),
113-
workQueue());
110+
config()->io_timeout.value_or(defaults::io_timeout));
114111
isReceiver = device.version() == std::make_tuple(1, 0);
115112
} catch(hidpp10::Error &e) {
116113
if(e.code() != hidpp10::Error::UnknownDevice)

src/logid/DeviceManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
namespace logid
3434
{
35-
class workqueue;
3635
class InputDevice;
3736

3837
class DeviceManager : public backend::raw::DeviceMonitor

src/logid/Receiver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ Receiver::Receiver(const std::string& path,
6666
const std::shared_ptr<DeviceManager>& manager) :
6767
dj::ReceiverMonitor(path,
6868
manager->config()->io_timeout.value_or(
69-
defaults::io_timeout),
70-
manager->workQueue()),
69+
defaults::io_timeout)),
7170
_path (path), _manager (manager), _nickname (manager),
7271
_ipc_node (manager->receiversNode()->make_child(_nickname)),
7372
_ipc_interface (_ipc_node->make_interface<ReceiverIPC>(this))

src/logid/actions/ChangeDPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void ChangeDPI::press()
3939
{
4040
_pressed = true;
4141
if(_dpi) {
42-
task::spawn(_device->workQueue(),
42+
spawn_task(
4343
[this]{
4444
try {
4545
uint16_t last_dpi = _dpi->getDPI(_config.sensor.value_or(0));

src/logid/actions/ChangeHostAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void ChangeHostAction::press()
4949
void ChangeHostAction::release()
5050
{
5151
if(_change_host) {
52-
task::spawn(_device->workQueue(),
52+
spawn_task(
5353
[this] {
5454
auto host_info = _change_host->getHostInfo();
5555
int next_host;

src/logid/actions/CycleDPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void CycleDPI::press()
4040
{
4141
_pressed = true;
4242
if(_dpi && !_config.dpis.empty()) {
43-
task::spawn(_device->workQueue(),
43+
spawn_task(
4444
[this](){
4545
std::lock_guard<std::mutex> lock(_dpi_lock);
4646
++_current_dpi;

src/logid/actions/ToggleHiresScroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void ToggleHiresScroll::press()
3838
_pressed = true;
3939
if(_hires_scroll)
4040
{
41-
task::spawn(_device->workQueue(),
41+
spawn_task(
4242
[hires=this->_hires_scroll](){
4343
auto mode = hires->getMode();
4444
mode ^= backend::hidpp20::HiresScroll::HiRes;

0 commit comments

Comments
 (0)