Skip to content

Commit 7328827

Browse files
committed
Wait notice in constructor
1 parent 7a499fa commit 7328827

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/pqrs/osx/iokit_hid_queue_value_monitor.hpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ class iokit_hid_queue_value_monitor final : public dispatcher::extra::dispatcher
4848
auto wait = make_thread_wait();
4949

5050
run_loop_thread_->enqueue(^{
51-
if (hid_device_.get_device()) {
52-
IOHIDDeviceRegisterRemovalCallback(*(hid_device_.get_device()),
51+
if (auto d = hid_device_.get_device()) {
52+
IOHIDDeviceRegisterRemovalCallback(*d,
5353
static_device_removal_callback,
5454
this);
5555

56-
IOHIDDeviceScheduleWithRunLoop(*(hid_device_.get_device()),
56+
IOHIDDeviceScheduleWithRunLoop(*d,
5757
run_loop_thread_->get_run_loop(),
5858
kCFRunLoopCommonModes);
5959
}
6060

6161
wait->notify();
6262
});
63+
64+
wait->wait_notice();
6365
}
6466

6567
virtual ~iokit_hid_queue_value_monitor(void) {
@@ -78,17 +80,15 @@ class iokit_hid_queue_value_monitor final : public dispatcher::extra::dispatcher
7880
run_loop_thread_->enqueue(^{
7981
stop({.check_requested_open_options = false});
8082

81-
if (hid_device_.get_device()) {
82-
IOHIDDeviceUnscheduleFromRunLoop(*(hid_device_.get_device()),
83+
if (auto d = hid_device_.get_device()) {
84+
IOHIDDeviceUnscheduleFromRunLoop(*d,
8385
run_loop_thread_->get_run_loop(),
8486
kCFRunLoopCommonModes);
8587
}
8688

8789
wait->notify();
8890
});
8991

90-
// Wait until all tasks are processed
91-
9292
wait->wait_notice();
9393
}
9494

0 commit comments

Comments
 (0)