20 #ifndef MPD_NFS_CANCELLABLE_HXX 21 #define MPD_NFS_CANCELLABLE_HXX 25 #include <boost/intrusive/list.hpp> 33 :
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
68 template<
typename T,
typename CT=CancellablePo
inter<T>>
75 typedef boost::intrusive::list<CT,
76 boost::intrusive::constant_time_size<false>> List;
77 typedef typename List::iterator iterator;
78 typedef typename List::const_iterator const_iterator;
88 constexpr
bool operator()(
const CT &a)
const {
95 return std::find_if(list.begin(), list.end(), MatchPointer(p));
100 return std::find_if(list.begin(), list.end(), MatchPointer(p));
104 iterator Find(CT &c) noexcept {
105 return list.iterator_to(c);
109 const_iterator Find(
const CT &c)
const noexcept {
110 return list.iterator_to(c);
117 for (
const auto &c : list)
118 if (!c.IsCancelled())
127 return Find(p) != list.end();
130 template<
typename... Args>
132 assert(Find(p) == list.end());
134 CT *c =
new CT(p, std::forward<Args>(args)...);
141 assert(i != list.end());
149 assert(i != list.end());
156 assert(i != list.end());
const T & const_reference_type
gcc_pure bool Contains(const_reference_type p) const noexcept
CT & Add(reference_type p, Args &&... args)
CT::reference_type reference_type
void Cancel(reference_type p)
CancellablePointer(reference_type _p)
Callbacks for an asynchronous libnfs operation.
constexpr bool IsCancelled() const
constexpr bool Is(const_reference_type other) const
gcc_pure bool IsEmpty() const noexcept
CT & Get(reference_type p) noexcept
CT::const_reference_type const_reference_type