event/SocketEvent: allow Schedule() with IMPLICIT_FLAGS
Relax the API (instead of tightening it further like commit
7bc1c9925b
tried to do unsuccessfully).
This commit is contained in:
parent
ad48834469
commit
b27e82e4a9
@ -60,6 +60,9 @@ SocketEvent::Abandon() noexcept
|
||||
bool
|
||||
SocketEvent::Schedule(unsigned flags) noexcept
|
||||
{
|
||||
if (flags != 0)
|
||||
flags |= IMPLICIT_FLAGS;
|
||||
|
||||
if (flags == GetScheduledFlags())
|
||||
return true;
|
||||
|
||||
@ -94,21 +97,11 @@ 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
|
||||
{
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user