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

Function TEST

test/bthread_setconcurrency_unittest.cpp:39–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39TEST(BthreadTest, setconcurrency) {
40 ASSERT_EQ(8 + BTHREAD_EPOLL_THREAD_NUM, (size_t)bthread_getconcurrency());
41 ASSERT_EQ(EINVAL, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY - 1));
42 ASSERT_EQ(EINVAL, bthread_setconcurrency(0));
43 ASSERT_EQ(EINVAL, bthread_setconcurrency(-1));
44 ASSERT_EQ(EINVAL, bthread_setconcurrency(BTHREAD_MAX_CONCURRENCY + 1));
45 ASSERT_EQ(0, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY));
46 ASSERT_EQ(BTHREAD_MIN_CONCURRENCY, bthread_getconcurrency());
47 ASSERT_EQ(0, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY + 1));
48 ASSERT_EQ(BTHREAD_MIN_CONCURRENCY + 1, bthread_getconcurrency());
49 ASSERT_EQ(0, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY)); // smaller value
50 bthread_t th;
51 ASSERT_EQ(0, bthread_start_urgent(&th, NULL, dummy, NULL));
52 ASSERT_EQ(BTHREAD_MIN_CONCURRENCY + 1, bthread_getconcurrency());
53 ASSERT_EQ(0, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY + 5));
54 ASSERT_EQ(BTHREAD_MIN_CONCURRENCY + 5, bthread_getconcurrency());
55 ASSERT_EQ(EPERM, bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY + 1));
56 ASSERT_EQ(BTHREAD_MIN_CONCURRENCY + 5, bthread_getconcurrency());
57}
58
59static butil::atomic<int> *odd;
60static butil::atomic<int> *even;

Callers

nothing calls this directly

Calls 13

bthread_getconcurrencyFunction · 0.85
bthread_setconcurrencyFunction · 0.85
bthread_start_urgentFunction · 0.85
bthread_start_backgroundFunction · 0.85
butex_wake_allFunction · 0.85
bthread_joinFunction · 0.85
set_min_concurrencyFunction · 0.85
get_min_concurrencyFunction · 0.85
current_tagFunction · 0.85
concurrency_by_tagFunction · 0.85
concurrencyMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected