5 #ifndef BITCOIN_RWCOLLECTION_H 6 #define BITCOIN_RWCOLLECTION_H 10 #include <boost/noncopyable.hpp> 11 #include <boost/range/iterator.hpp> 12 #include <boost/thread/locks.hpp> 13 #include <boost/thread/shared_mutex.hpp> 16 #include <type_traits> 25 using type = decltype(std::declval<T &>()[std::declval<I>()]);
31 : lock(
std::move(other.lock)), collection(other.collection) {}
39 using iterator =
typename boost::range_iterator<T>::type;
42 std::reverse_iterator<iterator>
rbegin() {
43 return std::rbegin(*collection);
45 std::reverse_iterator<iterator>
rend() {
return std::rend(*collection); }
50 std::reverse_iterator<const_iterator>
rbegin()
const {
51 return std::rbegin(*collection);
53 std::reverse_iterator<const_iterator>
rend()
const {
54 return std::rend(*collection);
61 return (*collection)[std::forward<I>(index)];
76 return ReadView(boost::shared_lock<boost::shared_mutex>(rwmutex),
83 return WriteView(boost::unique_lock<boost::shared_mutex>(rwmutex),
88 #endif // BITCOIN_RWCOLLECTION_H boost::shared_mutex rwmutex
RWCollectionView(L l, T &c)
const T * operator->() const
std::reverse_iterator< const_iterator > rend() const
typename boost::range_iterator< T >::type iterator
Iterator mechanics.
const_iterator begin() const
RWCollectionView(RWCollectionView &&other)
decltype(std::declval< T & >()[std::declval< I >()]) type
std::reverse_iterator< iterator > rbegin()
std::reverse_iterator< iterator > rend()
const_iterator end() const
std::reverse_iterator< const_iterator > rbegin() const
ReadView getReadView() const
typename boost::range_iterator< const T >::type const_iterator
BracketType< I >::type operator[](I &&index)
Forward bracket operator.