C/C++ API Reference
Loading...
Searching...
No Matches
pw::containers::internal::AsyncCountAndCapacity< SizeType, kMaxWakers > Class Template Reference

Overview

template<typename SizeType, size_t kMaxWakers = 1>
class pw::containers::internal::AsyncCountAndCapacity< SizeType, kMaxWakers >

Mix-in for containers that hold up to a certain number of items.

Non-intrusive containers such as deques, queues, and vectors track both their overall capacity and the number of items currently present. This type extends the basic CountAndCapacity functionality to add the ability to wake a task that is pending on enough space becoming available.

With a single-producer, single consumer queue, at most one task will be pending on the container at any one time. The kMaxWakers template parameter may be set to allow additional pending tasks, e.g. for a multi- producer, single consumer queue.

Public Types

using size_type = SizeType
 

Public Member Functions

constexpr AsyncCountAndCapacity (size_type capacity)
 
constexpr AsyncCountAndCapacity (AsyncCountAndCapacity &&other)
 
constexpr AsyncCountAndCapacityoperator= (AsyncCountAndCapacity &&other) noexcept
 
constexpr size_type capacity () const noexcept
 
constexpr size_type count () const noexcept
 
constexpr void SetCount (size_type count)
 
constexpr void IncrementCount (size_type n=1)
 
constexpr void DecrementCount (size_type n=1)
 
async2::Poll PendHasSpace (async2::Context &context, size_type num)
 
async2::Poll PendNotEmpty (async2::Context &context)
 Waits until an item is available in the container.
 
constexpr void SetCapacity (size_type capacity)
 

Member Function Documentation

◆ PendHasSpace()

template<typename SizeType , size_t kMaxWakers = 1>
async2::Poll pw::containers::internal::AsyncCountAndCapacity< SizeType, kMaxWakers >::PendHasSpace ( async2::Context context,
size_type  num 
)
inline

Waits until enough room is available in the container.

The num of requested elements must be less than the capacity.


The documentation for this class was generated from the following file: