mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +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
3 changed files with 13 additions and 2 deletions
|
@ -101,6 +101,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void may_have_become_unresponsive() {}
|
virtual void may_have_become_unresponsive() {}
|
||||||
|
virtual void did_become_responsive() {}
|
||||||
|
|
||||||
void post_message(const Message& message)
|
void post_message(const Message& message)
|
||||||
{
|
{
|
||||||
|
@ -130,6 +131,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(static_cast<size_t>(nwritten) == buffer.size());
|
ASSERT(static_cast<size_t>(nwritten) == buffer.size());
|
||||||
|
|
||||||
|
m_responsiveness_timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drain_messages_from_client()
|
void drain_messages_from_client()
|
||||||
|
@ -156,8 +159,10 @@ public:
|
||||||
bytes.append(buffer, nread);
|
bytes.append(buffer, nread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bytes.is_empty())
|
if (!bytes.is_empty()) {
|
||||||
m_responsiveness_timer->restart();
|
m_responsiveness_timer->stop();
|
||||||
|
did_become_responsive();
|
||||||
|
}
|
||||||
|
|
||||||
size_t decoded_bytes = 0;
|
size_t decoded_bytes = 0;
|
||||||
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
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
|
// ^ClientConnection
|
||||||
virtual void die() override;
|
virtual void die() override;
|
||||||
virtual void may_have_become_unresponsive() override;
|
virtual void may_have_become_unresponsive() override;
|
||||||
|
virtual void did_become_responsive() override;
|
||||||
|
|
||||||
void set_unresponsive(bool);
|
void set_unresponsive(bool);
|
||||||
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
void destroy_window(Window&, Vector<i32>& destroyed_window_ids);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue