event/SocketMonitor: Schedule() returns bool
This commit is contained in:
parent
a8661b5931
commit
732bdc800d
@ -68,20 +68,24 @@ SocketMonitor::Close() noexcept
|
|||||||
Steal().Close();
|
Steal().Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
SocketMonitor::Schedule(unsigned flags) noexcept
|
SocketMonitor::Schedule(unsigned flags) noexcept
|
||||||
{
|
{
|
||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
if (flags == GetScheduledFlags())
|
if (flags == GetScheduledFlags())
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
|
bool success;
|
||||||
if (scheduled_flags == 0)
|
if (scheduled_flags == 0)
|
||||||
loop.AddFD(fd.Get(), flags, *this);
|
success = loop.AddFD(fd.Get(), flags, *this);
|
||||||
else if (flags == 0)
|
else if (flags == 0)
|
||||||
loop.RemoveFD(fd.Get(), *this);
|
success = loop.RemoveFD(fd.Get(), *this);
|
||||||
else
|
else
|
||||||
loop.ModifyFD(fd.Get(), flags, *this);
|
success = loop.ModifyFD(fd.Get(), flags, *this);
|
||||||
|
|
||||||
scheduled_flags = flags;
|
if (success)
|
||||||
|
scheduled_flags = flags;
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -98,18 +98,22 @@ public:
|
|||||||
return scheduled_flags;
|
return scheduled_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Schedule(unsigned flags) noexcept;
|
/**
|
||||||
|
* @return true on success, false on error (with errno set if
|
||||||
|
* USE_EPOLL is defined)
|
||||||
|
*/
|
||||||
|
bool Schedule(unsigned flags) noexcept;
|
||||||
|
|
||||||
void Cancel() noexcept {
|
void Cancel() noexcept {
|
||||||
Schedule(0);
|
Schedule(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleRead() noexcept {
|
bool ScheduleRead() noexcept {
|
||||||
Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
|
return Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleWrite() noexcept {
|
bool ScheduleWrite() noexcept {
|
||||||
Schedule(GetScheduledFlags() | WRITE);
|
return Schedule(GetScheduledFlags() | WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelRead() noexcept {
|
void CancelRead() noexcept {
|
||||||
|
Loading…
Reference in New Issue
Block a user