From 725985379a63f1ce00c5177967132f3813430fbe Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Oct 2020 17:01:13 +0200 Subject: [PATCH] event/SocketEvent: add ScheduleImplicit(), Is{Read,Write}Pending() --- src/event/SocketEvent.cxx | 10 ++++++++++ src/event/SocketEvent.hxx | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/event/SocketEvent.cxx b/src/event/SocketEvent.cxx index b506e1e13..62fea1004 100644 --- a/src/event/SocketEvent.cxx +++ b/src/event/SocketEvent.cxx @@ -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 { diff --git a/src/event/SocketEvent.hxx b/src/event/SocketEvent.hxx index 4e1ebabca..feaca85ce 100644 --- a/src/event/SocketEvent.hxx +++ b/src/event/SocketEvent.hxx @@ -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; };