mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibCore: Add a Socket::set_idle() API that turns the notifiers on/off
When a socket's user doesn't need it to be active, but wants to keep it open, the socket's notifiers should not be enabled to avoid hogging the CPU with effectively useless notifications. This API can be used to disable said notifiers until the user needs the notifications.
This commit is contained in:
parent
830b0e8f2d
commit
29acb7fcf8
2 changed files with 9 additions and 0 deletions
|
@ -218,6 +218,14 @@ bool Socket::close()
|
|||
return IODevice::close();
|
||||
}
|
||||
|
||||
void Socket::set_idle(bool idle)
|
||||
{
|
||||
if (m_read_notifier)
|
||||
m_read_notifier->set_enabled(!idle);
|
||||
if (m_notifier)
|
||||
m_notifier->set_enabled(!idle);
|
||||
}
|
||||
|
||||
void Socket::ensure_read_notifier()
|
||||
{
|
||||
VERIFY(m_connected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue