36 #include <gtest/gtest.h> 43 #include <boost/shared_array.hpp> 44 #include <boost/bind.hpp> 45 #include <boost/thread.hpp> 56 virtual uint8_t *
serialize(uint8_t *write_ptr, uint32_t seq)
const { (void)seq;
return write_ptr; }
57 virtual uint8_t *
deserialize(uint8_t *read_ptr) {
return read_ptr; }
69 return boost::make_shared<FakeMessage>();
79 boost::mutex::scoped_lock lock(mutex_);
96 boost::function<void(void)>
cb_;
107 ASSERT_FALSE(queue.
full());
111 ASSERT_TRUE(queue.
full());
115 ASSERT_FALSE(queue.
full());
119 ASSERT_TRUE(queue.
full());
121 ASSERT_TRUE(queue.
ready());
125 ASSERT_TRUE(queue.
full());
130 ASSERT_EQ(helper->calls_, 2);
140 ASSERT_FALSE(queue.
full());
145 ASSERT_FALSE(queue.
full());
147 for (
int i = 0; i < 10000; ++i)
152 ASSERT_FALSE(queue.
full());
154 for (
int i = 0; i < 10000; ++i)
161 ASSERT_EQ(helper->calls_, 10001);
226 boost::barrier barrier(2);
248 boost::barrier bar(2);
252 boost::thread t1(
callThread, boost::ref(queue));
253 boost::thread t2(
callThread, boost::ref(queue));
257 ASSERT_EQ(helper->calls_, 2);
274 boost::thread t1(
callThread, boost::ref(queue));
275 boost::thread t2(
callThread, boost::ref(queue));
279 ASSERT_EQ(helper->calls_, 1);
281 ASSERT_EQ(helper->calls_, 2);
284 int main(
int argc,
char** argv)
286 testing::InitGoogleTest(&argc, argv);
288 return RUN_ALL_TESTS();
virtual uint8_t * serialize(uint8_t *write_ptr, uint32_t seq) const
virtual uint32_t serializationLength() const
boost::function< void(void)> cb_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
virtual const std::string __getMessageDefinition() const
virtual VoidConstPtr deserialize(const SubscriptionCallbackHelperDeserializeParams &)
virtual std::string getDataType()
void waitForBarrier(boost::barrier *bar)
int main(int argc, char **argv)
virtual CallbackInterface::CallResult call()
void push(const SubscriptionCallbackHelperPtr &helper, const MessageDeserializerPtr &deserializer, bool has_tracked_object, const VoidConstWPtr &tracked_object, bool nonconst_need_copy, ros::Time receipt_time=ros::Time(), bool *was_full=0)
virtual const std::string __getMD5Sum() const
boost::weak_ptr< void const > VoidConstWPtr
boost::shared_ptr< FakeSubHelper > FakeSubHelperPtr
virtual const std::type_info & getTypeInfo()
void callThread(SubscriptionQueue &queue)
virtual std::string getMD5Sum()
virtual const std::string __getDataType() const
void clearInCallbackCallback(SubscriptionQueue &queue)
void clearWhileThreadIsBlockingCallback(bool *done, boost::barrier *barrier)
virtual void call(SubscriptionCallbackHelperCallParams ¶ms)
TEST(SubscriptionQueue, queueSize)
virtual uint8_t * deserialize(uint8_t *read_ptr)