42 #include <boost/thread/mutex.hpp> 43 #include <boost/bind.hpp> 50 IntervalIntersector::IntervalIntersector(boost::function<
void (
const calibration_msgs::Interval&)> output_callback):
52 output_callback_(output_callback)
67 for (
size_t i=0; i<n; i++) {
74 mutexes[n].reset(
new boost::mutex());
75 for (
size_t i=0; i<n; i++) {
88 ROS_DEBUG(
"Got message on stream [%zu]", i);
89 boost::mutex::scoped_lock lock(*
mutexes[i]);
91 queues[i].push_back(interval_ptr);
93 if( interval_ptr->start == interval_ptr->end ) {
108 int queue_to_pop = -1;
110 for (
size_t i=0; i<
queues.size(); i++) {
123 boost::mutex::scoped_lock lock(*
mutexes[i]);
129 if (
queues[i][0]->start > start) {
130 start =
queues[i][0]->start;
132 if (
queues[i][0]->end < end) {
138 if (queue_to_pop < 0) {
139 ROS_ERROR(
"IntervalIntersection logic error");
146 calibration_msgs::Interval interval;
147 interval.start = start;
154 calibration_msgs::Interval interval;
155 interval.start = start;
156 interval.end = start;
160 boost::mutex::scoped_lock lock(*
mutexes[queue_to_pop]);
161 queues[queue_to_pop].pop_front();
168 calibration_msgs::IntervalStatus status;
174 status.names.resize(n);
175 status.yeild_rates.resize(n);
176 for (
size_t i=0; i<n; i++) {
177 boost::mutex::scoped_lock lock(*
mutexes[i]);
180 status.yeild_rates[i] = 0.0;
183 status.yeild_rates[i] = good / count;
vector< boost::shared_ptr< queue_stat > > queue_stats
const Time TIME_MIN(0, 1)
boost::function< void(const calibration_msgs::IntervalConstPtr &)> getNewInputStream()
vector< deque< calibration_msgs::IntervalConstPtr > > queues
boost::mutex processing_mutex
vector< boost::shared_ptr< boost::mutex > > mutexes
void inputCallback(const calibration_msgs::IntervalConstPtr &interval_ptr, size_t i)
Interval message callback.
boost::function< void(const calibration_msgs::Interval &)> output_callback_
ROSTIME_DECL const Time TIME_MAX
calibration_msgs::IntervalStatus get_status()