Commit 72598537 authored by Max Kellermann's avatar Max Kellermann

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

parent 8849b9b6
...@@ -95,6 +95,16 @@ SocketEvent::Schedule(unsigned flags) noexcept ...@@ -95,6 +95,16 @@ SocketEvent::Schedule(unsigned flags) noexcept
} }
void 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 SocketEvent::Dispatch() noexcept
{ {
const unsigned flags = std::exchange(ready_flags, 0) & const unsigned flags = std::exchange(ready_flags, 0) &
......
...@@ -167,6 +167,21 @@ public: ...@@ -167,6 +167,21 @@ public:
Schedule(GetScheduledFlags() & ~WRITE); 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: public:
void Dispatch() noexcept; void Dispatch() noexcept;
}; };
......
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