From 83371d1e9204d90c57ab33aa44e7a4257430592b Mon Sep 17 00:00:00 2001 From: fan Date: Sun, 9 Oct 2022 16:22:35 +0000 Subject: [PATCH] change the default EventDispatcher some functions' name Signed-off-by: fan --- src/brpc/event_dispatcher.h | 4 ++-- src/brpc/event_dispatcher_epoll.cpp | 4 ++-- src/brpc/event_dispatcher_kqueue.cpp | 4 ++-- src/brpc/socket.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/brpc/event_dispatcher.h b/src/brpc/event_dispatcher.h index b6cae400ac..e98e11c929 100644 --- a/src/brpc/event_dispatcher.h +++ b/src/brpc/event_dispatcher.h @@ -63,12 +63,12 @@ friend class Socket; // be used instead of EPOLL_CTL_ADD. When event arrives, // `Socket::HandleEpollOut' will be called with `socket_id' // Returns 0 on success, -1 otherwise and errno is set - int AddEpollOut(SocketId socket_id, int fd, bool pollin); + int AddMultiplex(SocketId socket_id, int fd, bool pollin); // Remove EPOLLOUT event on `fd'. If `pollin' is true, EPOLLIN event // will be kept and EPOLL_CTL_MOD will be used instead of EPOLL_CTL_DEL // Returns 0 on success, -1 otherwise and errno is set - int RemoveEpollOut(SocketId socket_id, int fd, bool pollin); + int RemoveMultiplex(SocketId socket_id, int fd, bool pollin); private: DISALLOW_COPY_AND_ASSIGN(EventDispatcher); diff --git a/src/brpc/event_dispatcher_epoll.cpp b/src/brpc/event_dispatcher_epoll.cpp index 07d485e6d4..7491d1220d 100644 --- a/src/brpc/event_dispatcher_epoll.cpp +++ b/src/brpc/event_dispatcher_epoll.cpp @@ -111,7 +111,7 @@ void EventDispatcher::Join() { } } -int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) { +int EventDispatcher::AddMultiplex(SocketId socket_id, int fd, bool pollin) { if (_epfd < 0) { errno = EINVAL; return -1; @@ -138,7 +138,7 @@ int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) { return 0; } -int EventDispatcher::RemoveEpollOut(SocketId socket_id, +int EventDispatcher::RemoveMultiplex(SocketId socket_id, int fd, bool pollin) { if (pollin) { epoll_event evt; diff --git a/src/brpc/event_dispatcher_kqueue.cpp b/src/brpc/event_dispatcher_kqueue.cpp index 614cd3bca3..980db34992 100644 --- a/src/brpc/event_dispatcher_kqueue.cpp +++ b/src/brpc/event_dispatcher_kqueue.cpp @@ -113,7 +113,7 @@ void EventDispatcher::Join() { } } -int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) { +int EventDispatcher::AddMultiplex(SocketId socket_id, int fd, bool pollin) { if (_epfd < 0) { errno = EINVAL; return -1; @@ -136,7 +136,7 @@ int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) { return 0; } -int EventDispatcher::RemoveEpollOut(SocketId socket_id, +int EventDispatcher::RemoveMultiplex(SocketId socket_id, int fd, bool pollin) { struct kevent evt; EV_SET(&evt, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 210ba9e9d0..c159c5ec9b 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1122,7 +1122,7 @@ int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) { // health checker which called `SetFailed' before const int expected_val = _epollout_butex->load(butil::memory_order_relaxed); EventDispatcher& edisp = GetGlobalEventDispatcher(fd); - if (edisp.AddEpollOut(id(), fd, pollin) != 0) { + if (edisp.AddMultiplex(id(), fd, pollin) != 0) { return -1; } @@ -1134,7 +1134,7 @@ int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) { } // Ignore return value since `fd' might have been removed // by `RemoveConsumer' in `SetFailed' - butil::ignore_result(edisp.RemoveEpollOut(id(), fd, pollin)); + butil::ignore_result(edisp.RemoveMultiplex(id(), fd, pollin)); errno = saved_errno; // Could be writable or spurious wakeup (by former epollout) return rc; @@ -1197,7 +1197,7 @@ int Socket::Connect(const timespec* abstime, // Add `sockfd' into epoll so that `HandleEpollOutRequest' will // be called with `req' when epoll event reaches if (GetGlobalEventDispatcher(sockfd). - AddEpollOut(connect_id, sockfd, false) != 0) { + AddMultiplex(connect_id, sockfd, false) != 0) { const int saved_errno = errno; PLOG(WARNING) << "Fail to add fd=" << sockfd << " into epoll"; s->SetFailed(saved_errno, "Fail to add fd=%d into epoll: %s", @@ -1331,7 +1331,7 @@ int Socket::HandleEpollOutRequest(int error_code, EpollOutRequest* req) { } // We've got the right to call user callback // The timer will be removed inside destructor of EpollOutRequest - GetGlobalEventDispatcher(req->fd).RemoveEpollOut(id(), req->fd, false); + GetGlobalEventDispatcher(req->fd).RemoveMultiplex(id(), req->fd, false); return req->on_epollout_event(req->fd, error_code, req->data); }