mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into newsatdispatcher
This commit is contained in:
		| @@ -38,6 +38,7 @@ | ||||
| #include <boost/crc.hpp> | ||||
| #include <boost/date_time/gregorian/gregorian.hpp> | ||||
| #include <boost/dynamic_bitset.hpp> | ||||
| #include <boost/exception/diagnostic_information.hpp> | ||||
| #include <algorithm>  // for std::reverse | ||||
| #include <chrono>     // std::chrono::seconds | ||||
| #include <cmath>      // for std::fmod | ||||
|   | ||||
| @@ -34,12 +34,12 @@ | ||||
|  | ||||
|  | ||||
| #include "concurrent_queue.h" | ||||
| #include "galileo_ephemeris.h" | ||||
| #include "glonass_gnav_ephemeris.h" | ||||
| #include "glonass_gnav_utc_model.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include <galileo_ephemeris.h> | ||||
| #include <gps_ephemeris.h> | ||||
| #include <gps_cnav_ephemeris.h> | ||||
| #include <glonass_gnav_ephemeris.h> | ||||
| #include <glonass_gnav_utc_model.h> | ||||
| #include "gps_cnav_ephemeris.h" | ||||
| #include "gps_ephemeris.h" | ||||
| #include <boost/asio.hpp> | ||||
| #include <boost/date_time/posix_time/posix_time.hpp> | ||||
| #include <glog/logging.h> | ||||
| @@ -48,6 +48,7 @@ | ||||
| #include <cstdint> | ||||
| #include <cstring>  // for memcpy | ||||
| #include <deque> | ||||
| #include <list> | ||||
| #include <map> | ||||
| #include <memory> | ||||
| #include <set> | ||||
|   | ||||
| @@ -39,6 +39,7 @@ | ||||
| #include "gps_cnav_ephemeris.h" | ||||
| #include "gps_ephemeris.h" | ||||
| #include "rtcm.h" | ||||
| #include <boost/exception/diagnostic_information.hpp> | ||||
| #include <glog/logging.h> | ||||
| #include <ctime>      // for tm | ||||
| #include <exception>  // for exception | ||||
|   | ||||
| @@ -31,8 +31,11 @@ | ||||
| #ifndef GNSS_SDR_CONCURRENT_QUEUE_H | ||||
| #define GNSS_SDR_CONCURRENT_QUEUE_H | ||||
|  | ||||
| #include <boost/thread.hpp> | ||||
| #include <chrono> | ||||
| #include <condition_variable> | ||||
| #include <mutex> | ||||
| #include <queue> | ||||
| #include <thread> | ||||
|  | ||||
| template <typename Data> | ||||
|  | ||||
| @@ -48,7 +51,7 @@ class Concurrent_Queue | ||||
| public: | ||||
|     void push(Data const& data) | ||||
|     { | ||||
|         boost::mutex::scoped_lock lock(the_mutex); | ||||
|         std::unique_lock<std::mutex> lock(the_mutex); | ||||
|         the_queue.push(data); | ||||
|         lock.unlock(); | ||||
|         the_condition_variable.notify_one(); | ||||
| @@ -56,13 +59,13 @@ public: | ||||
|  | ||||
|     bool empty() const | ||||
|     { | ||||
|         boost::mutex::scoped_lock lock(the_mutex); | ||||
|         std::unique_lock<std::mutex> lock(the_mutex); | ||||
|         return the_queue.empty(); | ||||
|     } | ||||
|  | ||||
|     bool try_pop(Data& popped_value) | ||||
|     { | ||||
|         boost::mutex::scoped_lock lock(the_mutex); | ||||
|         std::unique_lock<std::mutex> lock(the_mutex); | ||||
|         if (the_queue.empty()) | ||||
|             { | ||||
|                 return false; | ||||
| @@ -74,7 +77,7 @@ public: | ||||
|  | ||||
|     void wait_and_pop(Data& popped_value) | ||||
|     { | ||||
|         boost::mutex::scoped_lock lock(the_mutex); | ||||
|         std::unique_lock<std::mutex> lock(the_mutex); | ||||
|         while (the_queue.empty()) | ||||
|             { | ||||
|                 the_condition_variable.wait(lock); | ||||
| @@ -83,9 +86,25 @@ public: | ||||
|         the_queue.pop(); | ||||
|     } | ||||
|  | ||||
|     bool timed_wait_and_pop(Data& popped_value, int wait_ms) | ||||
|     { | ||||
|         std::unique_lock<std::mutex> lock(the_mutex); | ||||
|         if (the_queue.empty()) | ||||
|             { | ||||
|                 the_condition_variable.wait_for(lock, std::chrono::milliseconds(wait_ms)); | ||||
|                 if (the_queue.empty()) | ||||
|                     { | ||||
|                         return false; | ||||
|                     } | ||||
|             } | ||||
|         popped_value = the_queue.front(); | ||||
|         the_queue.pop(); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::queue<Data> the_queue; | ||||
|     mutable boost::mutex the_mutex; | ||||
|     boost::condition_variable the_condition_variable; | ||||
|     mutable std::mutex the_mutex; | ||||
|     std::condition_variable the_condition_variable; | ||||
| }; | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Javier Arribas
					Javier Arribas