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

Function TEST

be/src/util/thread-pool-test.cc:43–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43TEST(ThreadPoolTest, BasicTest) {
44 const int OFFERED_RANGE = 10000;
45 for (int i = 0; i < NUM_THREADS; ++i) {
46 thread_counters[i] = 0;
47 }
48
49 ThreadPool<int> thread_pool("thread-pool", "worker", 5, 250, Count);
50 ASSERT_OK(thread_pool.Init());
51 for (int i = 0; i <= OFFERED_RANGE; ++i) {
52 ASSERT_TRUE(thread_pool.Offer(i));
53 }
54
55 thread_pool.DrainAndShutdown();
56
57 // Check that Offer() after Shutdown() will return false
58 ASSERT_FALSE(thread_pool.Offer(-1));
59 EXPECT_EQ(0, thread_pool.GetQueueSize());
60
61 int expected_count = (OFFERED_RANGE * (OFFERED_RANGE + 1)) / 2;
62 int count = 0;
63 for (int i = 0; i < NUM_THREADS; ++i) {
64 lock_guard<mutex> l(thread_mutexes[i]);
65 LOG(INFO) << "Counter " << i << ": " << thread_counters[i];
66 count += thread_counters[i];
67 }
68
69 EXPECT_EQ(expected_count, count);
70}
71
72class SleepWorkItem : public SynchronousWorkItem {
73public:

Callers

nothing calls this directly

Calls 9

OfferMethod · 0.80
DrainAndShutdownMethod · 0.80
GetQueueSizeMethod · 0.80
SynchronousOfferMethod · 0.80
GetMessageMethod · 0.80
codeMethod · 0.80
getMethod · 0.65
resetMethod · 0.65
InitMethod · 0.45

Tested by

no test coverage detected