From 0fa4e1aee0b2903b93a6632212b34cafab197111 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 20 Oct 2018 22:56:09 +0200 Subject: [PATCH] adding typename --- libpEpAdapter/libpEpAdapter.vcxproj | 2 ++ libpEpAdapter/libpEpAdapter.vcxproj.filters | 6 ++++++ locked_queue.hh | 10 ++++++++-- pc_container.hh | 15 +++++++-------- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libpEpAdapter/libpEpAdapter.vcxproj b/libpEpAdapter/libpEpAdapter.vcxproj index cfeae10..7e4c003 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj +++ b/libpEpAdapter/libpEpAdapter.vcxproj @@ -140,6 +140,8 @@ + + diff --git a/libpEpAdapter/libpEpAdapter.vcxproj.filters b/libpEpAdapter/libpEpAdapter.vcxproj.filters index 349cfcd..3e8566b 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj.filters +++ b/libpEpAdapter/libpEpAdapter.vcxproj.filters @@ -29,5 +29,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/locked_queue.hh b/locked_queue.hh index 7a98d86..632c004 100644 --- a/locked_queue.hh +++ b/locked_queue.hh @@ -67,7 +67,6 @@ namespace utility return r; } - // returns true and set a copy of the last element and pop it from queue if there is any // returns false and leaves 'out' untouched if queue is empty even after 'end_time' bool try_pop_back(T& out, std::chrono::steady_clock::time_point end_time) @@ -82,7 +81,6 @@ namespace utility _q.pop_back(); return true; } - // returns true and set a copy of the first element and pop it from queue if there is any // returns false and leaves 'out' untouched if queue is empty even after 'end_time' @@ -108,6 +106,14 @@ namespace utility _cv.notify_one(); } + void emplace_back(const T& data) + { + { + Lock L(_mtx); + _q.emplace_back(data); + } + _cv.notify_one(); + } void push_front(const T& data) { diff --git a/pc_container.hh b/pc_container.hh index 26939b7..406649c 100644 --- a/pc_container.hh +++ b/pc_container.hh @@ -31,8 +31,8 @@ public: typedef std::list Container; - Container::const_iterator begin() const noexcept { return c.cbegin(); } - Container::const_iterator end() const noexcept { return c.cend(); } + typename Container::const_iterator begin() const noexcept { return c.cbegin(); } + typename Container::const_iterator end() const noexcept { return c.cend(); } std::size_t size() const noexcept { return c.size(); } bool empty() const noexcept { return c.empty(); } @@ -48,15 +48,14 @@ public: } // Beware: does not delete *pdata nor *cdata! That's producer's and consumer's task! - void erase(Container::const_iterator pos) + void erase(typename Container::const_iterator pos) { -// changed.push_back( *pos ); - changed.emplace_back(nullptr, pos->cdata); + changed.push_back( *pos ); c.erase(pos); } // notify Consumer about the changed element - void change(Container::const_iterator pos) + void change(typename Container::const_iterator pos) { changed.push_back( *pos ); } @@ -103,8 +102,8 @@ public: } private: - Container c; - locked_queue changed; + typename Container c; + ::utility::locked_queue< PC > changed; }; } // end of namespace pEp