Skip to content

Commit

Permalink
change the default EventDispatcher some functions' name
Browse files Browse the repository at this point in the history
Signed-off-by: fan <yfan3763@gmail.com>
  • Loading branch information
fansehep committed Oct 9, 2022
1 parent f804534 commit 83371d1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/brpc/event_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/event_dispatcher_epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/event_dispatcher_kqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 83371d1

Please sign in to comment.