Browse Source

adding typename

sync
Volker Birk 7 years ago
parent
commit
0fa4e1aee0
  1. 2
      libpEpAdapter/libpEpAdapter.vcxproj
  2. 6
      libpEpAdapter/libpEpAdapter.vcxproj.filters
  3. 10
      locked_queue.hh
  4. 15
      pc_container.hh

2
libpEpAdapter/libpEpAdapter.vcxproj

@ -140,6 +140,8 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="..\Adapter.hh" /> <ClInclude Include="..\Adapter.hh" />
<ClInclude Include="..\Adapter.hxx" /> <ClInclude Include="..\Adapter.hxx" />
<ClInclude Include="..\locked_queue.hh" />
<ClInclude Include="..\pc_container.hh" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

6
libpEpAdapter/libpEpAdapter.vcxproj.filters

@ -29,5 +29,11 @@
<ClInclude Include="..\Adapter.hxx"> <ClInclude Include="..\Adapter.hxx">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\locked_queue.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\pc_container.hh">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

10
locked_queue.hh

@ -67,7 +67,6 @@ namespace utility
return r; return r;
} }
// returns true and set a copy of the last element and pop it from queue if there is any // 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' // 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) bool try_pop_back(T& out, std::chrono::steady_clock::time_point end_time)
@ -83,7 +82,6 @@ namespace utility
return true; return true;
} }
// returns true and set a copy of the first element and pop it from queue if there is any // 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' // returns false and leaves 'out' untouched if queue is empty even after 'end_time'
bool try_pop_front(T& out, std::chrono::steady_clock::time_point end_time) bool try_pop_front(T& out, std::chrono::steady_clock::time_point end_time)
@ -108,6 +106,14 @@ namespace utility
_cv.notify_one(); _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) void push_front(const T& data)
{ {

15
pc_container.hh

@ -31,8 +31,8 @@ public:
typedef std::list<PC> Container; typedef std::list<PC> Container;
Container::const_iterator begin() const noexcept { return c.cbegin(); } typename Container::const_iterator begin() const noexcept { return c.cbegin(); }
Container::const_iterator end() const noexcept { return c.cend(); } typename Container::const_iterator end() const noexcept { return c.cend(); }
std::size_t size() const noexcept { return c.size(); } std::size_t size() const noexcept { return c.size(); }
bool empty() const noexcept { return c.empty(); } 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! // 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.push_back( *pos );
changed.emplace_back(nullptr, pos->cdata);
c.erase(pos); c.erase(pos);
} }
// notify Consumer about the changed element // notify Consumer about the changed element
void change(Container::const_iterator pos) void change(typename Container::const_iterator pos)
{ {
changed.push_back( *pos ); changed.push_back( *pos );
} }
@ -103,8 +102,8 @@ public:
} }
private: private:
Container c; typename Container c;
locked_queue<PC> changed; ::utility::locked_queue< PC > changed;
}; };
} // end of namespace pEp } // end of namespace pEp

Loading…
Cancel
Save