Skip to content

Commit a3a84ec

Browse files
committed
use dispatch queue instead of sleeping the main thread
1 parent 852dc38 commit a3a84ec

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/bar_manager.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,17 @@ void bar_manager_handle_system_will_sleep(struct bar_manager* bar_manager) {
10331033
}
10341034

10351035
void bar_manager_handle_system_woke(struct bar_manager* bar_manager) {
1036-
usleep(100000);
1037-
bar_manager->sleeps = false;
1038-
bar_manager_display_changed(bar_manager);
1039-
bar_manager_custom_events_trigger(bar_manager,
1040-
COMMAND_SUBSCRIBE_SYSTEM_WOKE,
1041-
NULL );
1036+
1037+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
1038+
usleep(100000);
1039+
dispatch_async(dispatch_get_main_queue(), ^{
1040+
bar_manager->sleeps = false;
1041+
bar_manager_display_changed(bar_manager);
1042+
bar_manager_custom_events_trigger(bar_manager,
1043+
COMMAND_SUBSCRIBE_SYSTEM_WOKE,
1044+
NULL );
1045+
});
1046+
});
10421047
}
10431048

10441049
void bar_manager_handle_notification(struct bar_manager* bar_manager, struct notification* notification) {

0 commit comments

Comments
 (0)