19#include "pw_async2/context.h"
20#include "pw_async2/poll.h"
21#include "pw_async2/try.h"
22#include "pw_containers/inline_async_deque.h"
23#include "pw_containers/inline_queue.h"
24#include "pw_containers/internal/async_count_and_capacity.h"
34template <
typename ValueType,
typename SizeType,
size_t kCapacity>
35class BasicInlineAsyncQueue;
41template <
typename ValueType,
42 size_t kCapacity = containers::internal::kGenericSized>
45template <
typename ValueType,
47 size_t kCapacity = containers::internal::kGenericSized>
51 containers::internal::kGenericSized> {
55 containers::internal::kGenericSized>;
59 using typename Base::const_iterator;
60 using typename Base::const_pointer;
61 using typename Base::const_reference;
62 using typename Base::difference_type;
63 using typename Base::iterator;
64 using typename Base::pointer;
65 using typename Base::reference;
66 using typename Base::size_type;
67 using typename Base::value_type;
74 : deque_(count, value) {}
79 typename InputIterator,
80 typename = containers::internal::EnableIfInputIterator<InputIterator>>
82 : deque_(start, finish) {}
93 template <
size_t kOtherCapacity>
101 : deque_(std::move(other.deque_)) {}
106 template <
size_t kOtherCapacity>
109 *
this = std::move(other);
113 const std::initializer_list<value_type>& list) {
114 deque_ = std::move(list);
120 deque_ = other.deque_;
127 template <
size_t kOtherCapacity>
130 deque_ = other.deque_;
136 deque_ = std::move(other.deque_);
143 template <
size_t kOtherCapacity>
146 deque_ = std::move(other.deque_);
150 template <
typename OtherValueType,
151 typename = containers::internal::EnableIfIterable<OtherValueType>>
153 deque_ = Deque(other.begin(), other.end());
159 static constexpr size_type max_size() {
return capacity(); }
160 static constexpr size_type capacity() {
return kCapacity; }
163 friend class BasicInlineAsyncQueue<ValueType,
165 containers::internal::kGenericSized>;
178template <typename ValueType, typename SizeType>
181 containers::internal::kGenericSized>
183 BasicInlineAsyncQueue<ValueType, SizeType>,
184 BasicInlineAsyncDeque<ValueType, SizeType>> {
187 using Base = containers::internal::
188 BasicInlineQueueImpl<BasicInlineAsyncQueue<ValueType, SizeType>,
Deque>;
191 using typename Base::const_iterator;
192 using typename Base::const_pointer;
193 using typename Base::const_reference;
194 using typename Base::difference_type;
195 using typename Base::iterator;
196 using typename Base::pointer;
197 using typename Base::reference;
198 using typename Base::size_type;
199 using typename Base::value_type;
203 return deque().PendHasSpace(context, num);
208 return deque().PendNotEmpty(context);
215 template <
typename,
typename>
216 friend class containers::internal::GenericQueue;
218 template <
size_t kCapacity>
221 Deque& deque() {
return static_cast<Derived<0>*
>(
this)->deque_; }
222 const Deque& deque()
const {
223 return static_cast<const Derived<0>*
>(
this)->deque_;
Definition: inline_async_deque.h:51
Definition: inline_async_queue.h:184
Definition: inline_async_queue.h:51
Definition: inline_queue.h:251
BasicInlineAsyncQueue(const BasicInlineAsyncQueue &other)
Copy constructs for matching capacity.
Definition: inline_async_queue.h:88
BasicInlineAsyncQueue(BasicInlineAsyncQueue< ValueType, SizeType, kOtherCapacity > &&other)
Definition: inline_async_queue.h:107
BasicInlineAsyncQueue & operator=(BasicInlineAsyncQueue< ValueType, SizeType, kOtherCapacity > &&other)
Definition: inline_async_queue.h:144
BasicInlineAsyncQueue & operator=(BasicInlineAsyncQueue &&other)
Move assigns from matching capacity.
Definition: inline_async_queue.h:135
BasicInlineAsyncQueue(const BasicInlineAsyncQueue< ValueType, SizeType, kOtherCapacity > &other)
Definition: inline_async_queue.h:94
async2::Poll PendHasSpace(async2::Context &context, size_type num=1)
Returns Pending until space for num elements is available.
Definition: inline_async_queue.h:202
BasicInlineAsyncQueue & operator=(const BasicInlineAsyncQueue< ValueType, SizeType, kOtherCapacity > &other)
Definition: inline_async_queue.h:128
BasicInlineAsyncQueue(BasicInlineAsyncQueue &&other)
Move constructs for matching capacity.
Definition: inline_async_queue.h:100
async2::Poll PendNotEmpty(async2::Context &context)
Returns Pending until an element is available.
Definition: inline_async_queue.h:207
BasicInlineAsyncQueue & operator=(const BasicInlineAsyncQueue &other)
Copy assigns from matching capacity.
Definition: inline_async_queue.h:119
The Pigweed namespace.
Definition: alignment.h:27