19#include "lib/stdcompat/type_traits.h"
20#include "pw_allocator/allocator.h"
21#include "pw_async2/callback_task.h"
22#include "pw_async2/dispatcher.h"
23#include "pw_async2/future.h"
24#include "pw_containers/deque.h"
25#include "pw_numeric/checked_arithmetic.h"
26#include "pw_result/result.h"
27#include "pw_sync/interrupt_spin_lock.h"
28#include "pw_sync/lock_annotations.h"
29#include "pw_sync/timed_thread_notification.h"
46class ReserveSendFuture;
51template <
typename T, u
int16_t kCapacity>
82 enum AllowClosed { kAllowClosed };
86 BaseChannelFuture(BaseChannel* channel, AllowClosed)
89 StoreAndAddRefIfNonnull(channel);
92 BaseChannelFuture(BaseChannelFuture&& other)
94 : channel_(other.channel_) {
98 BaseChannelFuture& MoveAssignFrom(BaseChannelFuture& other)
117 void StoreAndAddRefIfNonnull(BaseChannel* channel)
122 BaseChannel* channel_;
126 using List = FutureList<&BaseChannelFuture::core_>;
130template <
typename Derived,
typename T,
typename FutureValue>
156 return static_cast<Channel<T>*
>(base_channel());
160 using BaseChannelFuture::base_channel;
161 using BaseChannelFuture::MarkCompleted;
169 chrono::SystemClock::duration::max();
178 std::lock_guard lock(*
this);
179 return is_open_locked();
187 return ref_count_ != 0;
194 std::lock_guard lock(*
this);
201 send_futures_.Push(future);
207 receive_futures_.Push(future);
213 add_object(receiver_count_);
217 add_object(sender_count_);
221 add_object(handle_count_);
229 PW_DASSERT(reservations_ > 0);
234 remove_object(&sender_count_);
238 remove_object(&receiver_count_);
242 remove_object(&handle_count_);
255 receive_futures_.ResolveOneIfAvailable();
259 send_futures_.ResolveOneIfAvailable();
263 return reservations_;
268 if (is_open_locked()) {
285 return handle_count_ == 0 && (sender_count_ == 0 || receiver_count_ == 0);
291 virtual void Destroy() {}
317 using size_type = uint16_t;
325 template <
size_t kAlignment,
size_t kCapacity>
327 : dequeue_(storage) {}
330 [[nodiscard]] size_type capacity()
const {
return dequeue_.capacity(); }
331 [[nodiscard]] size_type size()
const {
return dequeue_.size(); }
332 [[nodiscard]]
bool empty()
const {
return dequeue_.empty(); }
333 [[nodiscard]]
auto deallocator()
const {
return dequeue_.deallocator(); }
334 [[nodiscard]] T& front() {
return dequeue_.front(); }
335 [[nodiscard]]
const T& front()
const {
return dequeue_.front(); }
337 void pop_front() { dequeue_.pop_front(); }
339 template <
typename U>
340 void push_back(U&& value) {
341 dequeue_.push_back(std::forward<U>(value));
344 template <
typename... Args>
345 void emplace_back(Args&&... args) {
346 dequeue_.emplace_back(std::forward<Args>(args)...);
357 using size_type = uint16_t;
366 explicit ChannelDeque(uint16_t capacity) : capacity_(capacity) {}
374 [[nodiscard]] size_type capacity()
const {
return capacity_; }
375 [[nodiscard]] size_type size()
const {
return size_; }
376 [[nodiscard]]
bool empty()
const {
return size_ == 0; }
377 [[nodiscard]]
Deallocator* deallocator()
const {
return deallocator_; }
380 PW_ASSERT(size_ < capacity_);
385 PW_ASSERT(size_ != 0);
391 : deallocator_(&alloc), capacity_(capacity) {}
394 uint16_t capacity_ = 0;
405 std::lock_guard guard(*
this);
406 if (is_open_locked()) {
415 std::lock_guard guard(*
this);
416 if (is_open_locked()) {
423 template <
typename U,
424 int&... kExplicitGuard,
425 std::enable_if_t<std::is_same_v<::cpp20::remove_cvref_t<U>, T>,
428 deque_.push_back(std::forward<U>(value));
432 template <
typename U,
433 int&... kExplicitGuard,
434 std::enable_if_t<!std::is_same_v<::cpp20::remove_cvref_t<U>, T> &&
435 std::is_constructible_v<T, U>,
438 PushAndWake(T(value));
446 template <
typename... Args>
448 deque_.emplace_back(std::forward<Args>(args)...);
453 if constexpr (std::is_void_v<T>) {
457 T value = std::move(deque_.front());
466 return remaining_capacity_locked() == 0;
470 std::lock_guard guard(*
this);
471 return remaining_capacity_locked();
474 uint16_t remaining_capacity_locked()
const
476 return deque_.capacity() - deque_.size() - reservations();
481 return deque_.capacity();
485 return deque_.empty();
488 template <
typename U,
489 int&... kExplicitGuard,
490 std::enable_if_t<std::is_same_v<::cpp20::remove_cvref_t<U>, T>,
493 std::lock_guard guard(*
this);
494 if (!is_open_locked()) {
500 PushAndWake(std::forward<U>(value));
504 template <
typename U,
505 int&... kExplicitGuard,
506 std::enable_if_t<!std::is_same_v<::cpp20::remove_cvref_t<U>, T> &&
507 std::is_constructible_v<T, U>,
510 return TrySend(T(value));
516 "TrySend() with no arguments is for notification channels only");
518 std::lock_guard guard(*
this);
519 if (!is_open_locked()) {
531 std::lock_guard guard(*
this);
532 if (deque_.empty()) {
536 if constexpr (std::is_void_v<T>) {
540 return Result(PopAndWake());
545 std::lock_guard guard(*
this);
546 if (!is_open_locked()) {
556 template <
typename... Args>
559 remove_reservation();
560 if (is_open_locked()) {
561 EmplaceAndWake(std::forward<Args>(args)...);
563 RemoveRefAndDestroyIfUnreferenced();
568 remove_reservation();
569 if (is_open_locked()) {
572 RemoveRefAndDestroyIfUnreferenced();
577 : deque_(std::move(deque)) {}
579 template <
size_t kAlignment,
size_t kCapacity>
587 return deque_.deallocator();
599 if (deque.capacity() == 0) {
612 Deallocator*
const deallocator = this->deallocator();
618template <
typename T, u
int16_t kCapacity>
628template <u
int16_t kCapacity>
651 return channel_ !=
nullptr && channel_->is_open();
669 : channel_(&channel) {
670 channel_->add_handle();
677 : channel_(std::exchange(other.channel_,
nullptr)) {}
679 BaseChannelHandle& operator=(BaseChannelHandle&& other)
noexcept
687 BaseChannel* channel_;
714 PW_ASSERT(channel() !=
nullptr);
721 PW_ASSERT(channel() !=
nullptr);
739 template <
typename U>
743 template <
typename U, u
int16_t kCapacity>
760 template <
typename U>
761 friend std::optional<std::tuple<MpscChannelHandle<U>,
Receiver<U>>>
764 template <
typename U, u
int16_t kCapacity>
781 template <
typename U>
782 friend std::optional<std::tuple<SpmcChannelHandle<U>,
Sender<U>>>
785 template <
typename U, u
int16_t kCapacity>
800 template <
typename U>
804 template <
typename U, u
int16_t kCapacity>
899template <
typename T, u
int16_t kCapacity>
903 template <
typename U, u
int16_t kCap>
907 template <
typename U, u
int16_t kCap>
908 friend std::tuple<MpscChannelHandle<U>,
Receiver<U>> CreateMpscChannel(
911 template <
typename U, u
int16_t kCap>
912 friend std::tuple<SpmcChannelHandle<U>,
Sender<U>> CreateSpmcChannel(
915 template <
typename U, u
int16_t kCap>
924 std::lock_guard lock(*
this);
925 return this->active_locked();
928 constexpr uint16_t capacity()
const {
return kCapacity; }
942 :
Base(std::move(other)) {}
947 return static_cast<ReceiveFuture&
>(this->MoveAssignFrom(other));
951 this->RemoveFromChannel();
961 template <
typename,
typename>
966 :
Base(channel, this->kAllowClosed) {}
969 if (this->channel() ==
nullptr) {
970 PW_DASSERT(this->is_pendable());
971 return Ready<std::optional<T>>(std::nullopt);
974 this->channel()->lock();
975 PW_DASSERT(this->is_pendable());
976 if (this->channel()->empty()) {
977 return this->StoreWakerForReceiveIfOpen(cx)
979 : Ready<std::optional<T>>(std::nullopt);
982 auto result =
Ready(this->channel()->PopAndWake());
999 :
Base(std::move(other)) {}
1004 return static_cast<ReceiveFuture&
>(this->MoveAssignFrom(other));
1008 this->RemoveFromChannel();
1018 template <
typename,
typename>
1023 :
Base(channel, this->kAllowClosed) {}
1026 if (this->channel() ==
nullptr) {
1027 PW_DASSERT(this->is_pendable());
1028 return Ready(
false);
1031 this->channel()->lock();
1032 PW_DASSERT(this->is_pendable());
1033 if (this->channel()->empty()) {
1034 return this->StoreWakerForReceiveIfOpen(cx) ?
Pending() :
Ready(
false);
1037 this->channel()->PopAndWake();
1044template <
typename T>
1047 constexpr Receiver() : channel_(
nullptr) {}
1053 : channel_(std::exchange(other.channel_,
nullptr)) {}
1056 if (
this == &other) {
1059 if (channel_ !=
nullptr) {
1060 channel_->remove_receiver();
1062 channel_ = std::exchange(other.channel_,
nullptr);
1067 if (channel_ !=
nullptr) {
1068 channel_->remove_receiver();
1085 if (channel_ ==
nullptr) {
1090 if constexpr (std::is_void_v<T>) {
1091 if (
Status result = channel_->TryReceive();
1092 result.ok() || result.IsFailedPrecondition()) {
1096 if (
Result<T> result = channel_->TryReceive();
1097 result.ok() || result.status().IsFailedPrecondition()) {
1103 std::conditional_t<std::is_void_v<T>, bool, std::optional<T>>;
1109 [&result, ¬ification](ReceiveType&& val) {
1110 result = std::move(val);
1114 dispatcher.Post(task);
1118 if constexpr (std::is_void_v<T>) {
1121 if (!result.has_value()) {
1132 if constexpr (std::is_void_v<T>) {
1135 if (!result.has_value()) {
1160 if (channel_ ==
nullptr) {
1164 return channel_->TryReceive();
1172 if (channel_ !=
nullptr) {
1173 channel_->remove_receiver();
1180 return channel_ !=
nullptr && channel_->is_open();
1184 template <
typename U>
1187 template <
typename U>
1188 friend std::optional<std::tuple<MpscChannelHandle<U>,
Receiver<U>>>
1191 template <
typename U, u
int16_t kCapacity>
1195 template <
typename U>
1199 template <
typename U, u
int16_t kCapacity>
1205 : channel_(&channel) {
1206 channel_->add_receiver();
1209 internal::Channel<T>* channel_;
1212template <
typename T>
1222 :
Base(
static_cast<Base&&
>(other)), value_(std::move(other.value_)) {}
1226 value_ = std::move(other.value_);
1228 return static_cast<SendFuture&
>(this->MoveAssignFrom(other));
1232 this->RemoveFromChannel();
1245 :
Base(channel), value_(value) {}
1249 :
Base(channel), value_(std::move(value)) {}
1252 if (this->channel() ==
nullptr) {
1253 PW_DASSERT(this->is_pendable());
1254 return Ready(
false);
1257 this->channel()->lock();
1258 PW_DASSERT(this->is_pendable());
1259 if (!this->channel()->is_open_locked()) {
1261 return Ready(
false);
1264 if (this->channel()->full()) {
1265 this->StoreWakerForSend(cx);
1269 this->channel()->PushAndWake(std::move(*value_));
1274 std::optional<T> value_;
1287 :
Base(
static_cast<Base&&
>(other)) {}
1292 return static_cast<SendFuture&
>(this->MoveAssignFrom(other));
1296 this->RemoveFromChannel();
1312 if (this->channel() ==
nullptr) {
1313 PW_DASSERT(this->is_pendable());
1314 return Ready(
false);
1317 this->channel()->lock();
1318 PW_DASSERT(this->is_pendable());
1319 if (!this->channel()->is_open_locked()) {
1321 return Ready(
false);
1324 if (this->channel()->full()) {
1325 this->StoreWakerForSend(cx);
1329 this->channel()->PushAndWake();
1341template <
typename T>
1348 : channel_(std::exchange(other.channel_,
nullptr)) {}
1351 if (
this == &other) {
1355 channel_ = std::exchange(other.channel_,
nullptr);
1362 template <
typename... Args>
1364 PW_ASSERT(channel_ !=
nullptr);
1365 channel_->CommitReservationAndRemoveRef(std::forward<Args>(args)...);
1369 void CommitNotification() {
1370 static_assert(std::is_void_v<T>,
1371 "CommitNotification() is for notification channels only.");
1372 PW_ASSERT(channel_ !=
nullptr);
1373 channel_->CommitNotificationReservationAndRemoveRef();
1379 if (channel_ !=
nullptr) {
1380 channel_->DropReservationAndRemoveRef();
1395 : channel_(&channel) {
1396 channel_->add_ref();
1399 internal::Channel<T>* channel_;
1402template <
typename T>
1406 std::optional<SendReservation<T>>> {
1408 using Base = internal::
1409 ChannelFuture<ReserveSendFuture, T, std::optional<SendReservation<T>>>;
1422 this->RemoveFromChannel();
1439 if (this->channel() ==
nullptr) {
1440 PW_DASSERT(this->is_pendable());
1441 return Ready<std::optional<SendReservation<T>>>(std::nullopt);
1444 this->channel()->lock();
1445 PW_DASSERT(this->is_pendable());
1446 if (!this->channel()->is_open_locked()) {
1448 return Ready<std::optional<SendReservation<T>>>(std::nullopt);
1451 if (this->channel()->remaining_capacity_locked() == 0) {
1452 this->StoreWakerForReserveSend(cx);
1456 this->channel()->add_reservation();
1464template <
typename T>
1467 constexpr Sender() : channel_(
nullptr) {}
1473 : channel_(std::exchange(other.channel_,
nullptr)) {}
1476 if (
this == &other) {
1479 if (channel_ !=
nullptr) {
1480 channel_->remove_sender();
1482 channel_ = std::exchange(other.channel_,
nullptr);
1487 if (channel_ !=
nullptr) {
1488 channel_->remove_sender();
1500 template <
typename U>
1506 static_assert(std::is_void_v<T>,
1507 "Send() with no arguments is for notification channels only");
1528 if (channel_ ==
nullptr) {
1531 return channel_->TryReserveSend();
1543 template <
typename U,
1544 int&... kExplicitGuard,
1545 std::enable_if_t<std::is_same_v<::cpp20::remove_cvref_t<U>, T>,
1548 if (channel_ ==
nullptr) {
1551 return channel_->TrySend(std::forward<U>(value));
1555 template <
typename U,
1556 int&... kExplicitGuard,
1557 std::enable_if_t<!std::is_same_v<::cpp20::remove_cvref_t<U>, T> &&
1558 std::is_constructible_v<T, U>,
1577 "TrySend() with no arguments is for notification channels only");
1578 if (channel_ ==
nullptr) {
1581 return channel_->TrySend();
1594 template <
typename U,
1595 int&... kExplicitGuard,
1596 std::enable_if_t<std::is_same_v<::cpp20::remove_cvref_t<U>, T>,
1602 return BlockingSendMoveOrCopy(dispatcher, std::forward<U>(value), timeout);
1606 template <
typename U,
1607 int&... kExplicitGuard,
1608 std::enable_if_t<!std::is_same_v<::cpp20::remove_cvref_t<U>, T> &&
1609 std::is_constructible_v<T, U>,
1615 return BlockingSendMoveOrCopy(dispatcher, T(value), timeout);
1631 return BlockingSendMoveOrCopy(dispatcher, timeout);
1639 if (channel_ !=
nullptr) {
1640 channel_->remove_sender();
1647 return channel_ !=
nullptr ? channel_->remaining_capacity() : 0;
1652 return channel_ !=
nullptr ? channel_->capacity() : 0;
1657 return channel_ !=
nullptr && channel_->is_open();
1661 template <
typename U>
1664 template <
typename U>
1665 friend std::optional<std::tuple<SpmcChannelHandle<U>,
Sender<U>>>
1668 template <
typename U, u
int16_t kCapacity>
1672 template <
typename U>
1676 template <
typename U, u
int16_t kCapacity>
1682 : channel_(&channel) {
1683 channel_->add_sender();
1686 template <
typename U>
1687 Status BlockingSendMoveOrCopy(Dispatcher& dispatcher,
1691 if (channel_ ==
nullptr) {
1695 if (Status status = channel_->TrySend(std::forward<U>(value));
1696 status.ok() || status.IsFailedPrecondition()) {
1700 return BlockingSendFuture(
1702 SendFuture<T>(channel_, std::forward<U>(value)),
1706 Status BlockingSendMoveOrCopy(Dispatcher& dispatcher,
1709 if (channel_ ==
nullptr) {
1713 if (Status status = channel_->TrySend();
1714 status.ok() || status.IsFailedPrecondition()) {
1718 return BlockingSendFuture(dispatcher, SendFuture<T>(channel_), timeout);
1721 Status BlockingSendFuture(Dispatcher& dispatcher,
1722 SendFuture<T>&& future,
1726 sync::TimedThreadNotification notification;
1729 [&status, ¬ification](
bool result) {
1730 status = result ?
OkStatus() : Status::FailedPrecondition();
1731 notification.release();
1734 dispatcher.Post(task);
1736 if (timeout == internal::Channel<T>::kWaitForever) {
1737 notification.acquire();
1741 if (!notification.try_acquire_for(timeout)) {
1748 internal::Channel<T>* channel_;
1764template <
typename T>
1766 uint16_t capacity) {
1768 if (channel ==
nullptr) {
1769 return std::nullopt;
1771 std::lock_guard lock(*channel);
1786template <
typename T, u
int16_t kCapacity>
1789 PW_DASSERT(!storage.active_locked());
1806template <
typename T>
1810 if (channel ==
nullptr) {
1811 return std::nullopt;
1813 std::lock_guard lock(*channel);
1828template <
typename T, u
int16_t kCapacity>
1832 PW_DASSERT(!storage.active_locked());
1849template <
typename T>
1853 if (channel ==
nullptr) {
1854 return std::nullopt;
1856 std::lock_guard lock(*channel);
1871template <
typename T, u
int16_t kCapacity>
1875 PW_DASSERT(!storage.active_locked());
1892template <
typename T>
1893std::optional<std::tuple<SpscChannelHandle<T>, Sender<T>, Receiver<T>>>
1896 if (channel ==
nullptr) {
1897 return std::nullopt;
1899 std::lock_guard lock(*channel);
1916template <
typename T, u
int16_t kCapacity>
1920 PW_DASSERT(!storage.active_locked());
1921 return std::make_tuple(
1930 channel_->RemoveRefAndDestroyIfUnreferenced();
Definition: allocator.h:42
T * New(Args &&... args)
Definition: allocator.h:66
Abstract interface for releasing memory.
Definition: deallocator.h:30
void Deallocate(void *ptr)
Definition: deallocator.h:316
static constexpr Status DeadlineExceeded()
Definition: status.h:177
static constexpr Status Unavailable()
Definition: status.h:304
static constexpr Status FailedPrecondition()
Definition: status.h:243
Definition: callback_task.h:44
Channel handle for a particular type T.
Definition: channel.h:696
Sender< T > CreateSender()
Definition: channel.h:713
Receiver< T > CreateReceiver()
Definition: channel.h:720
Definition: channel.h:901
bool active() const
Definition: channel.h:923
Definition: dispatcher.h:74
constexpr bool is_pendable() const
Definition: future.h:255
void MarkComplete()
Definition: future.h:306
constexpr bool is_complete() const
Definition: future.h:260
Definition: channel.h:856
Definition: channel.h:813
A handle to a multi-producer, multi-consumer channel.
Definition: channel.h:728
friend std::optional< MpmcChannelHandle< U > > CreateMpmcChannel(Allocator &, uint16_t)
Definition: channel.h:1765
A handle to a multi-producer, single-consumer channel.
Definition: channel.h:750
friend std::optional< std::tuple< MpscChannelHandle< U >, Receiver< U > > > CreateMpscChannel(Allocator &, uint16_t)
Definition: channel.h:1807
constexpr bool IsReady() const noexcept
Returns whether or not this value is Ready.
Definition: poll.h:211
Definition: channel.h:933
A receiver which reads values from an asynchronous channel.
Definition: channel.h:1045
friend std::optional< std::tuple< MpscChannelHandle< U >, Receiver< U > > > CreateMpscChannel(Allocator &, uint16_t)
Definition: channel.h:1807
bool is_open() const
Returns true if the channel is open.
Definition: channel.h:1179
std::conditional_t< std::is_void_v< T >, Status, Result< T > > TryReceive()
Definition: channel.h:1159
friend std::optional< std::tuple< SpscChannelHandle< U >, Sender< U >, Receiver< U > > > CreateSpscChannel(Allocator &, uint16_t)
Definition: channel.h:1894
void Disconnect()
Definition: channel.h:1171
std::conditional_t< std::is_void_v< T >, Status, Result< T > > BlockingReceive(Dispatcher &dispatcher, chrono::SystemClock::duration timeout=internal::Channel< T >::kWaitForever)
Definition: channel.h:1081
ReceiveFuture< T > Receive()
Definition: channel.h:1149
Definition: channel.h:1406
Definition: channel.h:1214
Definition: channel.h:1342
void Cancel()
Releases the reservation, making the space available for other senders.
Definition: channel.h:1378
void Commit(Args &&... args)
Commits a value to a reserved slot.
Definition: channel.h:1363
A sender which writes values to an asynchronous channel.
Definition: channel.h:1465
SendFuture< T > Send(U &&value)
Definition: channel.h:1501
Status TrySend(U &&value)
Definition: channel.h:1547
Result< SendReservation< T > > TryReserveSend()
Definition: channel.h:1527
friend std::optional< std::tuple< SpmcChannelHandle< U >, Sender< U > > > CreateSpmcChannel(Allocator &, uint16_t)
Definition: channel.h:1850
friend std::optional< std::tuple< SpscChannelHandle< U >, Sender< U >, Receiver< U > > > CreateSpscChannel(Allocator &, uint16_t)
Definition: channel.h:1894
ReserveSendFuture< T > ReserveSend()
Definition: channel.h:1516
uint16_t capacity() const
Returns the maximum capacity of the channel.
Definition: channel.h:1651
Status BlockingSend(Dispatcher &dispatcher, chrono::SystemClock::duration timeout=internal::Channel< T >::kWaitForever)
Definition: channel.h:1628
Status BlockingSend(Dispatcher &dispatcher, U &&value, chrono::SystemClock::duration timeout=internal::Channel< T >::kWaitForever)
Definition: channel.h:1598
uint16_t remaining_capacity() const
Returns the remaining capacity of the channel.
Definition: channel.h:1646
void Disconnect()
Definition: channel.h:1638
bool is_open() const
Returns true if the channel is open.
Definition: channel.h:1656
Status TrySend()
Definition: channel.h:1574
A handle to a single-producer, multi-consumer channel.
Definition: channel.h:771
friend std::optional< std::tuple< SpmcChannelHandle< U >, Sender< U > > > CreateSpmcChannel(Allocator &, uint16_t)
Definition: channel.h:1850
A handle to a single-producer, single-consumer channel.
Definition: channel.h:792
friend std::optional< std::tuple< SpscChannelHandle< U >, Sender< U >, Receiver< U > > > CreateSpscChannel(Allocator &, uint16_t)
Definition: channel.h:1894
bool is_complete() const
True if the future has returned Ready().
Definition: channel.h:75
bool is_pendable() const
True if the Pend can be called on the future.
Definition: channel.h:72
Definition: channel.h:642
Definition: channel.h:166
Definition: channel.h:620
Definition: channel.h:316
Definition: channel.h:131
Definition: channel.h:401
Definition: channel.h:595
Definition: interrupt_spin_lock.h:50
Definition: timed_thread_notification.h:40
bool try_acquire_for(chrono::SystemClock::duration timeout)
std::optional< std::tuple< SpmcChannelHandle< T >, Sender< T > > > CreateSpmcChannel(Allocator &alloc, uint16_t capacity)
Definition: channel.h:1850
std::optional< std::tuple< MpscChannelHandle< T >, Receiver< T > > > CreateMpscChannel(Allocator &alloc, uint16_t capacity)
Definition: channel.h:1807
std::optional< MpmcChannelHandle< T > > CreateMpmcChannel(Allocator &alloc, uint16_t capacity)
Definition: channel.h:1765
std::optional< std::tuple< SpscChannelHandle< T >, Sender< T >, Receiver< T > > > CreateSpscChannel(Allocator &alloc, uint16_t capacity)
Definition: channel.h:1894
std::conditional_t< std::is_void_v< typename T::value_type >, ReadyType, typename T::value_type > FutureValue
Definition: future.h:110
constexpr PendingType Pending()
Returns a value indicating that an operation was not yet able to complete.
Definition: poll.h:353
constexpr Poll Ready()
Returns a value indicating completion.
Definition: poll.h:337
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:91
constexpr bool CheckedIncrement(T &base, Inc inc)
Definition: checked_arithmetic.h:118
constexpr Status OkStatus()
Definition: status.h:450
#define PW_LOCKABLE(name)
Definition: lock_annotations.h:210
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60
#define PW_NO_LOCK_SAFETY_ANALYSIS
Definition: lock_annotations.h:296
#define PW_EXCLUSIVE_LOCK_FUNCTION(...)
Definition: lock_annotations.h:232
#define PW_EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: lock_annotations.h:147
#define PW_LOCK_RETURNED(x)
Definition: lock_annotations.h:199
#define PW_UNLOCK_FUNCTION(...)
Definition: lock_annotations.h:249
#define PW_LOCKS_EXCLUDED(...)
Definition: lock_annotations.h:178