event/Loop: pass SocketEvent& to AbandonFD()

This commit is contained in:
Max Kellermann 2020-10-28 14:58:23 +01:00
parent 46418d0f2d
commit 65a1c4a016
3 changed files with 6 additions and 5 deletions

View File

@ -103,13 +103,14 @@ EventLoop::Break() noexcept
} }
bool bool
EventLoop::AbandonFD(int _fd) noexcept EventLoop::AbandonFD(SocketEvent &event) noexcept
{ {
#ifdef HAVE_THREADED_EVENT_LOOP #ifdef HAVE_THREADED_EVENT_LOOP
assert(!IsAlive() || IsInside()); assert(!IsAlive() || IsInside());
#endif #endif
assert(event.IsDefined());
return poll_backend.Abandon(_fd); return poll_backend.Abandon(event.GetSocket().Get());
} }
bool bool

View File

@ -196,7 +196,7 @@ public:
* has been closed. This is like RemoveFD(), but does not * has been closed. This is like RemoveFD(), but does not
* attempt to use #EPOLL_CTL_DEL. * attempt to use #EPOLL_CTL_DEL.
*/ */
bool AbandonFD(int fd) noexcept; bool AbandonFD(SocketEvent &event) noexcept;
void AddIdle(IdleEvent &i) noexcept; void AddIdle(IdleEvent &i) noexcept;

View File

@ -44,7 +44,7 @@ SocketEvent::Close() noexcept
return; return;
if (std::exchange(scheduled_flags, 0) != 0) if (std::exchange(scheduled_flags, 0) != 0)
loop.AbandonFD(fd.Get()); loop.AbandonFD(*this);
fd.Close(); fd.Close();
} }
@ -52,7 +52,7 @@ void
SocketEvent::Abandon() noexcept SocketEvent::Abandon() noexcept
{ {
if (std::exchange(scheduled_flags, 0) != 0) if (std::exchange(scheduled_flags, 0) != 0)
loop.AbandonFD(fd.Get()); loop.AbandonFD(*this);
fd = SocketDescriptor::Undefined(); fd = SocketDescriptor::Undefined();
} }