36 #include <boost/thread.hpp>
38 #include <gtest/gtest.h>
59 boost::mutex::scoped_lock lock(mutex_);
62 initial_call_id = boost::this_thread::get_id();
66 if (initial_call_id != boost::this_thread::get_id())
94 boost::barrier bar(1);
96 for (uint32_t i = 0; i < 10; ++i)
98 queue->addCallback(cb, 0);
101 while (cb->calls < 10)
106 EXPECT_EQ(cb->calls, 10U);
107 ASSERT_TRUE(cb->success);
112 uint32_t thread_count = boost::thread::hardware_concurrency();
114 if (thread_count == 1)
124 boost::barrier bar(2);
127 for (uint32_t i = 0; i < 10; ++i)
129 queue1->addCallback(cb1, 1);
130 queue2->addCallback(cb2, 1);
133 while (cb1->calls < 10 || cb2->calls < 10)
138 EXPECT_EQ(cb1->calls, 10U);
139 EXPECT_EQ(cb2->calls, 10U);
140 EXPECT_TRUE(cb1->success);
141 EXPECT_TRUE(cb2->success);
142 EXPECT_NE(cb1->initial_call_id, cb2->initial_call_id);
166 for (uint32_t j = 0; j < 1000; ++j)
174 boost::barrier bar(num_threads + 1);
177 for (uint32_t i = 0; i < num_threads; ++i)
179 queue->addCallback(cb, 0);
183 queue->removeByID(0);
187 int main(
int argc,
char** argv)
189 ::testing::InitGoogleTest(&argc, argv);
190 return RUN_ALL_TESTS();