16 #include <boost/thread.hpp>
17 #include <boost/thread/mutex.hpp>
18 #include <glog/logging.h>
19 #include <gtest/gtest.h>
28 TEST(BlockingQueueTest, TestBasic) {
42 TEST(BlockingQueueTest, TestGetFromShutdownQueue) {
68 lock_guard<mutex> guard(
lock_);
82 lock_guard<mutex> guard(
lock_);
90 threads_.push_back(shared_ptr<thread>(
92 threads_.push_back(shared_ptr<thread>(
97 threads_.push_back(shared_ptr<thread>(
100 for (
int i = 0; i <
threads_.size(); ++i) {
105 lock_guard<mutex> guard(
lock_);
133 TEST(BlockingQueueTest, TestMultipleThreads) {
140 int main(
int argc,
char **argv) {
141 ::testing::InitGoogleTest(&argc, argv);
142 return RUN_ALL_TESTS();
int main(int argc, char **argv)
bool BlockingPut(const T &val)
vector< shared_ptr< thread > > ThreadVector
void InserterThread(int arg)
BlockingQueue< int32_t > queue_
void Shutdown()
Shut down the queue. Wakes up all threads waiting on BlockingGet or BlockingPut.
map< int32_t, int > gotten_