mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
CSocket: Add an on_ready_to_read callback.
This callback uses a CNotifier internally and will fire whenever there's something to be read from the socket.
This commit is contained in:
parent
8f4fba95c0
commit
82446ea701
2 changed files with 17 additions and 0 deletions
|
@ -137,3 +137,16 @@ bool CSocket::listen()
|
|||
set_error(errno);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
void CSocket::did_update_fd(int fd)
|
||||
{
|
||||
if (fd < 0) {
|
||||
m_read_notifier = nullptr;
|
||||
return;
|
||||
}
|
||||
m_read_notifier = make<CNotifier>(fd, CNotifier::Event::Read);
|
||||
m_read_notifier->on_ready_to_read = [this] {
|
||||
if (on_ready_to_read)
|
||||
on_ready_to_read();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue