Commit b27e82e4 authored by Max Kellermann's avatar Max Kellermann

event/SocketEvent: allow Schedule() with IMPLICIT_FLAGS

Relax the API (instead of tightening it further like commit 7bc1c992 tried to do unsuccessfully).
parent ad488344
......@@ -60,6 +60,9 @@ SocketEvent::Abandon() noexcept
bool
SocketEvent::Schedule(unsigned flags) noexcept
{
if (flags != 0)
flags |= IMPLICIT_FLAGS;
if (flags == GetScheduledFlags())
return true;
......@@ -95,20 +98,10 @@ SocketEvent::Schedule(unsigned flags) noexcept
}
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
{
const unsigned flags = std::exchange(ready_flags, 0) &
(GetScheduledFlags() | IMPLICIT_FLAGS);
GetScheduledFlags();
if (flags != 0)
callback(flags);
......
......@@ -165,10 +165,10 @@ public:
/**
* 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;
void ScheduleImplicit() noexcept {
Schedule(IMPLICIT_FLAGS);
}
bool IsReadPending() const noexcept {
return GetScheduledFlags() & READ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment