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:
@@ -60,6 +60,9 @@ SocketEvent::Abandon() noexcept
|
|||||||
bool
|
bool
|
||||||
SocketEvent::Schedule(unsigned flags) noexcept
|
SocketEvent::Schedule(unsigned flags) noexcept
|
||||||
{
|
{
|
||||||
|
if (flags != 0)
|
||||||
|
flags |= IMPLICIT_FLAGS;
|
||||||
|
|
||||||
if (flags == GetScheduledFlags())
|
if (flags == GetScheduledFlags())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -94,21 +97,11 @@ SocketEvent::Schedule(unsigned flags) noexcept
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SocketEvent::ScheduleImplicit() noexcept
|
|
||||||
{
|
|
||||||
assert(IsDefined());
|
|
||||||
assert(scheduled_flags == 0);
|
|
||||||
|
|
||||||
scheduled_flags = IMPLICIT_FLAGS;
|
|
||||||
loop.AddFD(fd.Get(), scheduled_flags, *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SocketEvent::Dispatch() noexcept
|
SocketEvent::Dispatch() noexcept
|
||||||
{
|
{
|
||||||
const unsigned flags = std::exchange(ready_flags, 0) &
|
const unsigned flags = std::exchange(ready_flags, 0) &
|
||||||
(GetScheduledFlags() | IMPLICIT_FLAGS);
|
GetScheduledFlags();
|
||||||
|
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
callback(flags);
|
callback(flags);
|
||||||
|
@@ -165,10 +165,10 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule only the #IMPLICIT_FLAGS without #READ and #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;
|
void ScheduleImplicit() noexcept {
|
||||||
|
Schedule(IMPLICIT_FLAGS);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsReadPending() const noexcept {
|
bool IsReadPending() const noexcept {
|
||||||
return GetScheduledFlags() & READ;
|
return GetScheduledFlags() & READ;
|
||||||
|
Reference in New Issue
Block a user