File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
SerialPrograms/Source/CommonFramework/Environment Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -112,16 +112,22 @@ bool AppleSleepController::enable_sleep(){
112112void AppleSleepController::update_state (){
113113 // Must call under lock.
114114
115+ SleepSuppress before_state = m_state.load (std::memory_order_relaxed);
116+ SleepSuppress after_state = SleepSuppress::NONE;
117+
115118 // TODO: Distiguish these two.
116119 bool enabled = m_screen_on_requests > 0 || m_no_sleep_requests > 0 ;
117- prevent_sleep ();
118-
119- m_state.store (
120- enabled
121- ? SleepSuppress::SCREEN_ON
122- : SleepSuppress::NONE,
123- std::memory_order_release
124- );
120+ prevent_sleep (enabled);
121+
122+ after_state = enabled
123+ ? SleepSuppress::SCREEN_ON
124+ : SleepSuppress::NONE,
125+
126+ m_state.store (after_state, std::memory_order_release);
127+
128+ if (before_state != after_state){
129+ notify_listeners (after_state);
130+ }
125131}
126132
127133
You can’t perform that action at this time.
0 commit comments