Android-cuttlefish cvd tool
|
#include <unique_resource_allocator.h>
Classes | |
class | Reservation |
struct | ReservationHash |
Public Types | |
using | ReservationSet = std::unordered_set< Reservation, ReservationHash > |
Public Member Functions | |
std::vector< T > | ExpandPool (std::vector< T > another_pool) |
std::vector< T > | ExpandPool (T &&t) |
std::vector< T > | ExpandPool (const T &t) |
std::optional< Reservation > | UniqueItem () |
std::optional< ReservationSet > | UniqueItems (const int n) |
template<typename V = T> | |
std::enable_if_t< std::is_integral< V >::value, std::optional< ReservationSet > > | UniqueConsecutiveItems (const std::size_t n) |
std::optional< Reservation > | Take (const T &t) |
template<typename Container > | |
std::optional< ReservationSet > | TakeAll (const Container &ts) |
template<typename V = T> | |
std::enable_if_t< std::is_integral< V >::value, std::optional< ReservationSet > > | TakeRange (const T &start_inclusive, const T &end_exclusive) |
Static Public Member Functions | |
static UniqueResourceAllocator & | Create (const std::vector< T > &pool) |
static std::unique_ptr< UniqueResourceAllocator > | New (const std::vector< T > &pool) |
Private Types | |
template<typename U > | |
using | RemoveCvref = typename std::remove_cv_t< typename std::remove_reference_t< U > > |
Private Member Functions | |
template<typename Container > | |
UniqueResourceAllocator (const Container &items) | |
bool | operator== (const UniqueResourceAllocator &other) const |
void | Reclaim (const T &t) |
template<typename V = T> | |
std::enable_if_t< std::is_integral< V >::value, std::optional< ReservationSet > > | TakeRangeInternal (const T &start_inclusive, const T &end_exclusive) |
const T * | RemoveFromPool (const typename std::set< T >::iterator itr) |
Private Attributes | |
std::set< T > | available_resources_ |
std::unordered_set< T > | allocated_resources_ |
std::mutex | mutex_ |
Generic allocator that can provide RAII-aware resource reservations.
See go/cf-resource-allocator-utils for more details.
|
private |
using cuttlefish::UniqueResourceAllocator< T >::ReservationSet = std::unordered_set<Reservation, ReservationHash> |
|
inlineprivate |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |