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

Function client_thread

test/bthread_fd_unittest.cpp:195–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void* client_thread(void* arg) {
196 ClientMeta* m = (ClientMeta*)arg;
197 for (size_t i = 0; i < m->times; ++i) {
198 if (write(m->fd, &m->count, sizeof(m->count)) != sizeof(m->count)) {
199 LOG(FATAL) << "Should not happen in this test";
200 return NULL;
201 }
202#ifdef RUN_CLIENT_IN_BTHREAD
203 ssize_t rc;
204 do {
205# if defined(OS_LINUX)
206 const int wait_rc = bthread_fd_wait(m->fd, EPOLLIN);
207# elif defined(OS_MACOSX)
208 const int wait_rc = bthread_fd_wait(m->fd, EVFILT_READ);
209# endif
210 EXPECT_EQ(0, wait_rc) << berror();
211 rc = read(m->fd, &m->count, sizeof(m->count));
212 } while (rc < 0 && errno == EAGAIN);
213#else
214 ssize_t rc = read(m->fd, &m->count, sizeof(m->count));
215#endif
216 if (rc != sizeof(m->count)) {
217 PLOG(FATAL) << "Should not happen in this test, rc=" << rc;
218 return NULL;
219 }
220 }
221 return NULL;
222}
223
224inline uint32_t fmix32 ( uint32_t h ) {
225 h ^= h >> 16;

Callers

nothing calls this directly

Calls 2

bthread_fd_waitFunction · 0.85
berrorFunction · 0.85

Tested by

no test coverage detected