Skip to content

Commit 552bd30

Browse files
Remove implementation specific function name of EventDispatcher (#2462)
* Remove implementation specific function name of EventDispatcher * Deregister to Unregister * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp * Update socket.cpp
1 parent f60af19 commit 552bd30

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/brpc/event_dispatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ friend class rdma::RdmaEndpoint;
6464
// be used instead of EPOLL_CTL_ADD. When event arrives,
6565
// `Socket::HandleEpollOut' will be called with `socket_id'
6666
// Returns 0 on success, -1 otherwise and errno is set
67-
int AddEpollOut(SocketId socket_id, int fd, bool pollin);
67+
int RegisterEvent(SocketId socket_id, int fd, bool pollin);
6868

6969
// Remove EPOLLOUT event on `fd'. If `pollin' is true, EPOLLIN event
7070
// will be kept and EPOLL_CTL_MOD will be used instead of EPOLL_CTL_DEL
7171
// Returns 0 on success, -1 otherwise and errno is set
72-
int RemoveEpollOut(SocketId socket_id, int fd, bool pollin);
72+
int UnregisterEvent(SocketId socket_id, int fd, bool pollin);
7373

7474
private:
7575
DISALLOW_COPY_AND_ASSIGN(EventDispatcher);

src/brpc/event_dispatcher_epoll.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void EventDispatcher::Join() {
111111
}
112112
}
113113

114-
int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) {
114+
int EventDispatcher::RegisterEvent(SocketId socket_id, int fd, bool pollin) {
115115
if (_epfd < 0) {
116116
errno = EINVAL;
117117
return -1;
@@ -138,7 +138,7 @@ int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) {
138138
return 0;
139139
}
140140

141-
int EventDispatcher::RemoveEpollOut(SocketId socket_id,
141+
int EventDispatcher::UnregisterEvent(SocketId socket_id,
142142
int fd, bool pollin) {
143143
if (pollin) {
144144
epoll_event evt;

src/brpc/event_dispatcher_kqueue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void EventDispatcher::Join() {
113113
}
114114
}
115115

116-
int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) {
116+
int EventDispatcher::RegisterEvent(SocketId socket_id, int fd, bool pollin) {
117117
if (_epfd < 0) {
118118
errno = EINVAL;
119119
return -1;
@@ -136,7 +136,7 @@ int EventDispatcher::AddEpollOut(SocketId socket_id, int fd, bool pollin) {
136136
return 0;
137137
}
138138

139-
int EventDispatcher::RemoveEpollOut(SocketId socket_id,
139+
int EventDispatcher::UnregisterEvent(SocketId socket_id,
140140
int fd, bool pollin) {
141141
struct kevent evt;
142142
EV_SET(&evt, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);

src/brpc/socket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) {
12341234
// health checker which called `SetFailed' before
12351235
const int expected_val = _epollout_butex->load(butil::memory_order_relaxed);
12361236
EventDispatcher& edisp = GetGlobalEventDispatcher(fd, _bthread_tag);
1237-
if (edisp.AddEpollOut(id(), fd, pollin) != 0) {
1237+
if (edisp.RegisterEvent(id(), fd, pollin) != 0) {
12381238
return -1;
12391239
}
12401240

@@ -1246,7 +1246,7 @@ int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) {
12461246
}
12471247
// Ignore return value since `fd' might have been removed
12481248
// by `RemoveConsumer' in `SetFailed'
1249-
butil::ignore_result(edisp.RemoveEpollOut(id(), fd, pollin));
1249+
butil::ignore_result(edisp.UnregisterEvent(id(), fd, pollin));
12501250
errno = saved_errno;
12511251
// Could be writable or spurious wakeup (by former epollout)
12521252
return rc;
@@ -1309,7 +1309,7 @@ int Socket::Connect(const timespec* abstime,
13091309

13101310
// Add `sockfd' into epoll so that `HandleEpollOutRequest' will
13111311
// be called with `req' when epoll event reaches
1312-
if (GetGlobalEventDispatcher(sockfd, _bthread_tag).AddEpollOut(connect_id, sockfd, false) !=
1312+
if (GetGlobalEventDispatcher(sockfd, _bthread_tag).RegisterEvent(connect_id, sockfd, false) !=
13131313
0) {
13141314
const int saved_errno = errno;
13151315
PLOG(WARNING) << "Fail to add fd=" << sockfd << " into epoll";
@@ -1450,7 +1450,7 @@ int Socket::HandleEpollOutRequest(int error_code, EpollOutRequest* req) {
14501450
}
14511451
// We've got the right to call user callback
14521452
// The timer will be removed inside destructor of EpollOutRequest
1453-
GetGlobalEventDispatcher(req->fd, _bthread_tag).RemoveEpollOut(id(), req->fd, false);
1453+
GetGlobalEventDispatcher(req->fd, _bthread_tag).UnregisterEvent(id(), req->fd, false);
14541454
return req->on_epollout_event(req->fd, error_code, req->data);
14551455
}
14561456

0 commit comments

Comments
 (0)