mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 21:41:02 +00:00
Wait for OS messages when is possible
With this change we will reduce the CPU and energy consumption levels as now we can go to sleep when there is no OS messages left and no timers running.
This commit is contained in:
parent
b275c24793
commit
efffde5673
2
laf
2
laf
@ -1 +1 @@
|
|||||||
Subproject commit d727d1e53ca08fd38e99dacdef5b3fd643a83b63
|
Subproject commit e189f488718dac5ef9a7c285f69aca724dce4714
|
@ -189,7 +189,7 @@ Manager::~Manager()
|
|||||||
set_mouse_cursor(kNoCursor);
|
set_mouse_cursor(kNoCursor);
|
||||||
|
|
||||||
// Destroy timers
|
// Destroy timers
|
||||||
Timer::checkNoTimers();
|
ASSERT(!Timer::haveTimers());
|
||||||
|
|
||||||
// Destroy filters
|
// Destroy filters
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -325,8 +325,10 @@ void Manager::generateMessagesFromOSEvents()
|
|||||||
// Events from "she" layer.
|
// Events from "she" layer.
|
||||||
os::Event sheEvent;
|
os::Event sheEvent;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// bool canWait = (msg_queue.empty());
|
// TODO Add timers to laf::os library so we can wait for then in
|
||||||
bool canWait = false;
|
// the OS message loop.
|
||||||
|
bool canWait = (msg_queue.empty() &&
|
||||||
|
!Timer::haveRunningTimers());
|
||||||
|
|
||||||
m_eventQueue->getEvent(sheEvent, canWait);
|
m_eventQueue->getEvent(sheEvent, canWait);
|
||||||
if (sheEvent.type() == os::Event::None)
|
if (sheEvent.type() == os::Event::None)
|
||||||
|
@ -97,9 +97,21 @@ void Timer::pollTimers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::checkNoTimers()
|
bool Timer::haveTimers()
|
||||||
{
|
{
|
||||||
ASSERT(timers.empty());
|
return !timers.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Timer::haveRunningTimers()
|
||||||
|
{
|
||||||
|
if (!timers.empty()) {
|
||||||
|
for (auto timer : timers) {
|
||||||
|
if (timer && timer->isRunning()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
@ -36,7 +36,8 @@ namespace ui {
|
|||||||
obs::signal<void()> Tick;
|
obs::signal<void()> Tick;
|
||||||
|
|
||||||
static void pollTimers();
|
static void pollTimers();
|
||||||
static void checkNoTimers();
|
static bool haveTimers();
|
||||||
|
static bool haveRunningTimers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onTick();
|
virtual void onTick();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user