MCPcopy Create free account
hub / github.com/apache/brpc / process_thread

Function process_thread

test/bthread_fd_unittest.cpp:87–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85
86const size_t NCLIENT = 30;
87void* process_thread(void* arg) {
88 SocketMeta* m = (SocketMeta*)arg;
89 size_t count;
90 //printf("begin to process fd=%d\n", m->fd);
91 ssize_t n = read(m->fd, &count, sizeof(count));
92 if (n != sizeof(count)) {
93 LOG(FATAL) << "Should not happen in this test";
94 return NULL;
95 }
96 count += NCLIENT;
97 //printf("write result=%lu to fd=%d\n", count, m->fd);
98 if (write(m->fd, &count, sizeof(count)) != sizeof(count)) {
99 LOG(FATAL) << "Should not happen in this test";
100 return NULL;
101 }
102#ifdef CREATE_THREAD_TO_PROCESS
103# if defined(OS_LINUX)
104 epoll_event evt = { EPOLLIN | EPOLLONESHOT, { m } };
105 if (epoll_ctl(m->epfd, EPOLL_CTL_MOD, m->fd, &evt) < 0) {
106 epoll_ctl(m->epfd, EPOLL_CTL_ADD, m->fd, &evt);
107 }
108# elif defined(OS_MACOSX)
109 struct kevent kqueue_event;
110 EV_SET(&kqueue_event, m->fd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_ONESHOT,
111 0, 0, m);
112 kevent(m->epfd, &kqueue_event, 1, NULL, 0, NULL);
113# endif
114#endif
115 return NULL;
116}
117
118void* epoll_thread(void* arg) {
119 bthread_usleep(1);

Callers 1

epoll_threadFunction · 0.70

Calls 1

keventClass · 0.70

Tested by

no test coverage detected