mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibIPC: Only start responsiveness timer after sending client a message
Instead of always running the responsiveness timer for IPC clients, we now only start it after sending a message. This avoids waking up otherwise idle clients to do ping/pong busywork.
This commit is contained in:
parent
47df0cbbc8
commit
4ab1b0b436
Notes:
sideshowbarker
2024-07-19 05:40:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4ab1b0b4368
3 changed files with 13 additions and 2 deletions
|
@ -101,6 +101,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void may_have_become_unresponsive() {}
|
||||
virtual void did_become_responsive() {}
|
||||
|
||||
void post_message(const Message& message)
|
||||
{
|
||||
|
@ -130,6 +131,8 @@ public:
|
|||
}
|
||||
|
||||
ASSERT(static_cast<size_t>(nwritten) == buffer.size());
|
||||
|
||||
m_responsiveness_timer->start();
|
||||
}
|
||||
|
||||
void drain_messages_from_client()
|
||||
|
@ -156,8 +159,10 @@ public:
|
|||
bytes.append(buffer, nread);
|
||||
}
|
||||
|
||||
if (!bytes.is_empty())
|
||||
m_responsiveness_timer->restart();
|
||||
if (!bytes.is_empty()) {
|
||||
m_responsiveness_timer->stop();
|
||||
did_become_responsive();
|
||||
}
|
||||
|
||||
size_t decoded_bytes = 0;
|
||||
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
||||
|
|
|
@ -844,4 +844,9 @@ void ClientConnection::may_have_become_unresponsive()
|
|||
});
|
||||
}
|
||||
|
||||
void ClientConnection::did_become_responsive()
|
||||
{
|
||||
set_unresponsive(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ private:
|
|||
// ^ClientConnection
|
||||
virtual void die() override;
|
||||
virtual void may_have_become_unresponsive() override;
|
||||
virtual void did_become_responsive() override;
|
||||
|
||||
void set_unresponsive(bool);
|
||||
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
||||
|
|
Loading…
Add table
Reference in a new issue