Commit d4b151ed authored by Roman Orlov's avatar Roman Orlov Committed by Facebook Github Bot

Replace Boost iterator_facade with Folly analogue (#1187)

Summary:
Folly already has its own lightweight implementation `IteratorFacade`. It depends only a few STL headers thus saves compilation time.
Pull Request resolved: https://github.com/facebook/folly/pull/1187

Reviewed By: LeeHowes

Differential Revision: D16147453

Pulled By: yfeldblum

fbshipit-source-id: 9559a095e242ee7e16659558d505777159f6e534
parent c2fcc1b6
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <type_traits> #include <type_traits>
#include <folly/detail/AtomicHashUtils.h> #include <folly/detail/AtomicHashUtils.h>
#include <folly/detail/Iterators.h>
#include <folly/lang/Bits.h> #include <folly/lang/Bits.h>
#include <folly/lang/Exception.h> #include <folly/lang/Exception.h>
...@@ -485,10 +486,10 @@ struct AtomicHashArray< ...@@ -485,10 +486,10 @@ struct AtomicHashArray<
Allocator, Allocator,
ProbeFcn, ProbeFcn,
KeyConvertFcn>::aha_iterator KeyConvertFcn>::aha_iterator
: boost::iterator_facade< : detail::IteratorFacade<
aha_iterator<ContT, IterVal>, aha_iterator<ContT, IterVal>,
IterVal, IterVal,
boost::forward_traversal_tag> { std::forward_iterator_tag> {
explicit aha_iterator() : aha_(nullptr) {} explicit aha_iterator() : aha_(nullptr) {}
// Conversion ctor for interoperability between const_iterator and // Conversion ctor for interoperability between const_iterator and
...@@ -519,7 +520,8 @@ struct AtomicHashArray< ...@@ -519,7 +520,8 @@ struct AtomicHashArray<
private: private:
friend class AtomicHashArray; friend class AtomicHashArray;
friend class boost::iterator_core_access; friend class detail::
IteratorFacade<aha_iterator, IterVal, std::forward_iterator_tag>;
void increment() { void increment() {
++offset_; ++offset_;
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include <atomic> #include <atomic>
#include <boost/iterator/iterator_facade.hpp>
#include <folly/ThreadCachedInt.h> #include <folly/ThreadCachedInt.h>
#include <folly/Utility.h> #include <folly/Utility.h>
#include <folly/hash/Hash.h> #include <folly/hash/Hash.h>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#endif #endif
#include <folly/detail/AtomicHashUtils.h> #include <folly/detail/AtomicHashUtils.h>
#include <folly/detail/Iterators.h>
#include <type_traits> #include <type_traits>
...@@ -568,10 +569,10 @@ struct AtomicHashMap< ...@@ -568,10 +569,10 @@ struct AtomicHashMap<
Allocator, Allocator,
ProbeFcn, ProbeFcn,
KeyConvertFcn>::ahm_iterator KeyConvertFcn>::ahm_iterator
: boost::iterator_facade< : detail::IteratorFacade<
ahm_iterator<ContT, IterVal, SubIt>, ahm_iterator<ContT, IterVal, SubIt>,
IterVal, IterVal,
boost::forward_traversal_tag> { std::forward_iterator_tag> {
explicit ahm_iterator() : ahm_(nullptr) {} explicit ahm_iterator() : ahm_(nullptr) {}
// Conversion ctor for interoperability between const_iterator and // Conversion ctor for interoperability between const_iterator and
...@@ -598,7 +599,8 @@ struct AtomicHashMap< ...@@ -598,7 +599,8 @@ struct AtomicHashMap<
explicit ahm_iterator(ContT* ahm, uint32_t subMap, const SubIt& subIt) explicit ahm_iterator(ContT* ahm, uint32_t subMap, const SubIt& subIt)
: ahm_(ahm), subMap_(subMap), subIt_(subIt) {} : ahm_(ahm), subMap_(subMap), subIt_(subIt) {}
friend class boost::iterator_core_access; friend class detail::
IteratorFacade<ahm_iterator, IterVal, std::forward_iterator_tag>;
void increment() { void increment() {
CHECK(!isEnd()); CHECK(!isEnd());
......
...@@ -81,8 +81,6 @@ ...@@ -81,8 +81,6 @@
#pragma once #pragma once
#define FOLLY_ATOMICHASHMAP_H_ #define FOLLY_ATOMICHASHMAP_H_
#include <boost/iterator/iterator_facade.hpp>
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include <stdexcept> #include <stdexcept>
......
...@@ -125,12 +125,12 @@ Sample usage: ...@@ -125,12 +125,12 @@ Sample usage:
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include <boost/iterator/iterator_facade.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <folly/ConcurrentSkipList-inl.h> #include <folly/ConcurrentSkipList-inl.h>
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/detail/Iterators.h>
#include <folly/synchronization/MicroSpinLock.h> #include <folly/synchronization/MicroSpinLock.h>
namespace folly { namespace folly {
...@@ -158,7 +158,7 @@ class ConcurrentSkipList { ...@@ -158,7 +158,7 @@ class ConcurrentSkipList {
typedef T key_type; typedef T key_type;
typedef detail::csl_iterator<value_type, NodeType> iterator; typedef detail::csl_iterator<value_type, NodeType> iterator;
typedef detail::csl_iterator<const value_type, const NodeType> const_iterator; typedef detail::csl_iterator<const value_type, NodeType> const_iterator;
class Accessor; class Accessor;
class Skipper; class Skipper;
...@@ -709,10 +709,10 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Accessor { ...@@ -709,10 +709,10 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Accessor {
// implements forward iterator concept. // implements forward iterator concept.
template <typename ValT, typename NodeT> template <typename ValT, typename NodeT>
class detail::csl_iterator : public boost::iterator_facade< class detail::csl_iterator : public detail::IteratorFacade<
csl_iterator<ValT, NodeT>, csl_iterator<ValT, NodeT>,
ValT, ValT,
boost::forward_traversal_tag> { std::forward_iterator_tag> {
public: public:
typedef ValT value_type; typedef ValT value_type;
typedef value_type& reference; typedef value_type& reference;
...@@ -738,9 +738,10 @@ class detail::csl_iterator : public boost::iterator_facade< ...@@ -738,9 +738,10 @@ class detail::csl_iterator : public boost::iterator_facade<
} }
private: private:
friend class boost::iterator_core_access;
template <class, class> template <class, class>
friend class csl_iterator; friend class csl_iterator;
friend class detail::
IteratorFacade<csl_iterator, ValT, std::forward_iterator_tag>;
void increment() { void increment() {
node_ = node_->next(); node_ = node_->next();
......
...@@ -18,17 +18,17 @@ ...@@ -18,17 +18,17 @@
#error This file may only be included from folly/io/RecordIO.h #error This file may only be included from folly/io/RecordIO.h
#endif #endif
#include <boost/iterator/iterator_facade.hpp> #include <folly/detail/Iterators.h>
#include <folly/hash/SpookyHashV2.h> #include <folly/hash/SpookyHashV2.h>
namespace folly { namespace folly {
class RecordIOReader::Iterator : public boost::iterator_facade< class RecordIOReader::Iterator : public detail::IteratorFacade<
RecordIOReader::Iterator, RecordIOReader::Iterator,
const std::pair<ByteRange, off_t>, const std::pair<ByteRange, off_t>,
boost::forward_traversal_tag> { std::forward_iterator_tag> {
friend class boost::iterator_core_access; friend class detail::
IteratorFacade<Iterator, value_type, std::forward_iterator_tag>;
friend class RecordIOReader; friend class RecordIOReader;
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment