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

Method Run

be/src/util/blocking-queue-test.cc:150–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 }
149
150 void Run() {
151 for (int i = 0; i < nthreads_; ++i) {
152 threads_.push_back(shared_ptr<thread>(
153 new thread(boost::bind(&MultiThreadTest::InserterThread, this, i))));
154 threads_.push_back(shared_ptr<thread>(
155 new thread(boost::bind(&MultiThreadTest::RemoverThread, this))));
156 }
157 // We add an extra thread to ensure that there aren't enough elements in
158 // the queue to go around. This way, we test removal after Shutdown.
159 threads_.push_back(shared_ptr<thread>(
160 new thread(boost::bind(
161 &MultiThreadTest::RemoverThread, this))));
162 for (int i = 0; i < threads_.size(); ++i) {
163 threads_[i]->join();
164 }
165
166 // Let's check to make sure we got what we should have.
167 lock_guard<mutex> guard(lock_);
168 for (int i = 0; i < nthreads_; ++i) {
169 ASSERT_EQ(iterations_, gotten_[i]);
170 }
171 // And there were nthreads_ * (iterations_ + 1) elements removed, but only
172 // nthreads_ * iterations_ elements added. So some removers hit the shutdown
173 // case.
174 ASSERT_EQ(iterations_, gotten_[-1]);
175 }
176
177 private:
178 typedef vector<shared_ptr<thread>> ThreadVector;

Callers 1

TESTFunction · 0.45

Calls 4

bindFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected