event/SocketEvent: add ScheduleImplicit(), Is{Read,Write}Pending()

This commit is contained in:
Max Kellermann 2020-10-15 17:01:13 +02:00
parent 8849b9b62c
commit 725985379a
2 changed files with 25 additions and 0 deletions

View File

@ -94,6 +94,16 @@ SocketEvent::Schedule(unsigned flags) noexcept
return success;
}
void
SocketEvent::ScheduleImplicit() noexcept
{
assert(IsDefined());
assert(scheduled_flags == 0);
scheduled_flags = IMPLICIT_FLAGS;
loop.AddFD(fd.Get(), scheduled_flags, *this);
}
void
SocketEvent::Dispatch() noexcept
{

View File

@ -167,6 +167,21 @@ public:
Schedule(GetScheduledFlags() & ~WRITE);
}
/**
* Schedule only the #IMPLICIT_FLAGS without #READ and #WRITE.
* This is not possible with Schedule(), and no other
* ScheduleX()/CancelX() method may be called on this object.
*/
void ScheduleImplicit() noexcept;
bool IsReadPending() const noexcept {
return GetScheduledFlags() & READ;
}
bool IsWritePending() const noexcept {
return GetScheduledFlags() & WRITE;
}
public:
void Dispatch() noexcept;
};