16 #include <unordered_map>
20 inline namespace _V1 {
61 : MRecord{Record}, MGenericCommands{GenericCommandsCapacity},
62 MAllocateDependency{
std::move(AllocateDependency)} {}
65 if (MGenericCommands.
empty())
66 return iterator{*
this, beginHostAccessor()};
74 if (MGenericCommands.
empty())
92 std::vector<value_type>
toVector()
const;
99 return MGenericCommands;
103 return MHostAccessorCommands;
107 template <
bool IsConst,
typename T>
struct Iterator;
109 template <
typename T>
struct Iterator<true, T> {
110 using type =
typename T::const_iterator;
113 template <
typename T>
struct Iterator<false, T> {
114 using type =
typename T::iterator;
117 using HostAccessorCommandSingleXRefT =
118 typename HostAccessorCommandsT::iterator;
119 using HostAccessorCommandsXRefT =
120 std::unordered_map<EmptyCommand *, HostAccessorCommandSingleXRefT>;
122 MemObjRecord *MRecord;
125 HostAccessorCommandsXRefT MHostAccessorCommandsXRef;
130 bool addHostAccessorCommand(EmptyCommand *Cmd,
EnqueueListT &ToEnqueue);
133 void insertHostAccessorCommand(EmptyCommand *Cmd);
135 size_t eraseHostAccessorCommand(EmptyCommand *Cmd);
137 typename Iterator<false, HostAccessorCommandsT>::type beginHostAccessor() {
138 return MHostAccessorCommands.begin();
141 typename Iterator<true, HostAccessorCommandsT>::type
142 beginHostAccessor()
const {
143 return MHostAccessorCommands.begin();
146 typename Iterator<false, HostAccessorCommandsT>::type endHostAccessor() {
147 return MHostAccessorCommands.end();
150 typename Iterator<true, HostAccessorCommandsT>::type endHostAccessor()
const {
151 return MHostAccessorCommands.end();
155 friend class IteratorT<true>;
156 friend class IteratorT<false>;
158 template <
bool IsConst,
typename T>
struct Ref;
159 template <
typename T>
struct Ref<true, T> {
160 using type =
const T &;
162 template <
typename T>
struct Ref<false, T> {
166 template <
bool IsConst,
typename T>
struct Ptr;
167 template <
typename T>
struct Ptr<true, T> {
168 using type =
const T *;
170 template <
typename T>
struct Ptr<false, T> {
179 using HostT =
typename Ref<IsConst, LeavesCollection>::type;
180 using GCItT =
typename Iterator<IsConst, GenericCommandsT>::type;
181 using HACItT =
typename Iterator<IsConst, HostAccessorCommandsT>::type;
188 bool MGenericIsActive;
191 : MHost(Host), MGCIt(GCIt), MHACIt(HACIt),
192 MGenericIsActive(GenericIsActive) {}
196 :
IteratorT(Host,
std::move(GCIt), Host.beginHostAccessor(), true) {}
203 : MHost{Other.MHost}, MGCIt(Other.MGCIt), MHACIt(Other.MHACIt),
204 MGenericIsActive(Other.MGenericIsActive) {}
207 : MHost{Other.MHost}, MGCIt(
std::move(Other.MGCIt)),
208 MHACIt(
std::move(Other.MHACIt)),
209 MGenericIsActive(Other.MGenericIsActive) {}
213 return &MHost == &Rhs.MHost && MGenericIsActive == Rhs.MGenericIsActive &&
214 ((MGenericIsActive && MGCIt == Rhs.MGCIt) ||
215 (!MGenericIsActive && MHACIt == Rhs.MHACIt));
219 return &MHost != &Rhs.MHost || MGenericIsActive != Rhs.MGenericIsActive ||
220 ((MGenericIsActive && MGCIt != Rhs.MGCIt) ||
221 (!MGenericIsActive && MHACIt != Rhs.MHACIt));
241 if (MGenericIsActive && MGCIt != MHost.MGenericCommands.end())
244 if (!MGenericIsActive && MHACIt != MHost.endHostAccessor())
254 if (MGenericIsActive) {
257 if (MGCIt == MHost.MGenericCommands.end()) {
258 MGenericIsActive =
false;
259 MHACIt = MHost.MHostAccessorCommands.begin();
266 assert(MGCIt == MHost.MGenericCommands.end());
268 if (MHACIt == MHost.endHostAccessor())
std::size_t capacity() const
The Command class represents some action that needs to be performed on one or more memory objects.
IteratorT(HostT Host, GCItT GCIt)
bool operator!=(const IteratorT< IsConst > &Rhs) const
typename Ref< IsConst, LeavesCollection >::type HostT
IteratorT< IsConst > operator++(int)
IteratorT< IsConst > & operator++()
IteratorT(IteratorT< IsConst > &&Other)
IteratorT & operator=(const IteratorT< IsConst > &)=delete
typename Iterator< IsConst, HostAccessorCommandsT >::type HACItT
value_type operator*() const
IteratorT(HostT Host, HACItT HACIt)
IteratorT(const IteratorT< IsConst > &Other)
typename Iterator< IsConst, GenericCommandsT >::type GCItT
bool operator==(const IteratorT< IsConst > &Rhs) const
A wrapper for CircularBuffer class along with collection for host accessor's EmptyCommands.
CircularBuffer< Command * > GenericCommandsT
std::list< EmptyCommand * > HostAccessorCommandsT
size_t genericCommandsCapacity() const
const GenericCommandsT & getGenericCommands() const
LeavesCollection(MemObjRecord *Record, std::size_t GenericCommandsCapacity, AllocateDependencyF AllocateDependency)
const_iterator cbegin() const
size_t remove(value_type Cmd)
Replacement for std::remove with subsequent call to erase(newEnd, end()).
bool push_back(value_type Cmd, EnqueueListT &ToEnqueue)
Returns true if insertion took place. Returns false otherwise.
std::function< void(Command *, Command *, MemObjRecord *, EnqueueListT &)> AllocateDependencyF
const HostAccessorCommandsT getHostAccessorCommands() const
std::vector< value_type > toVector() const
std::vector< Command * > EnqueueListT
const_iterator cend() const