CFx SDK Documentation
2023 SP0
|
#include <slot.h>
Public Types | |
using | slot_id = decltype(slot_id_helper(std::declval< IDGenerator >())) |
using | slot = basic_slot< T, slot_id > |
using | callback = typename slot::callback |
using | allocator_type = typename std::allocator_traits< Allocator >::template rebind_traits< slot >::allocator_type |
using | container_type = std::vector< slot, allocator_type > |
using | value_type = typename container_type::value_type |
using | reference = typename container_type::reference |
using | const_reference = typename container_type::const_reference |
using | size_type = typename container_type::size_type |
using | pointer = typename container_type::pointer |
using | iterator = typename container_type::iterator |
using | const_iterator = typename container_type::const_iterator |
Public Member Functions | |
slot_list () | |
slot_list (allocator_type alloc) | |
slot_list (slot_list &&)=default | |
slot_list (const slot_list &)=default | |
bool | try_lock () |
void | lock () |
void | unlock () |
bool | locked () const noexcept(noexcept(bool(std::declval< FlagType >()))) |
slot_id | push (const value_type &value) |
slot_id | push (value_type &&value) |
template<class... Args> | |
slot_id | emplace (Args &&... args) |
template<class U , class... Args> | |
slot_id | emplace_extended (Args &&... args) |
iterator | erase (const_iterator position) |
iterator | erase (const_iterator begin, const_iterator end) |
iterator | begin () |
iterator | end () |
const_iterator | cbegin () const |
const_iterator | cend () const |
size_type | active_size () const |
reference | back () |
const_reference | cback () const |
size_type | pending_size () const |
size_type | total_size () const |
void | clear () |
bool | active_empty () const |
bool | pending_empty () const |
bool | empty () const |
iterator | find (slot_id index) noexcept |
const_iterator | find (slot_id index) const noexcept |
Specialized container adaptor for slot/callback values Because of some assumptions we can make about how signals will use this list, we can achieve great performance boosts over using a standard containers alone Requirements: T must meet all requirements of Container SlotID must be post-incrementable, equality comparable and less than comparable SlotID must always be unique for new values added to the list SlotID must always increase in value for new values (new slots must compare greater than old slots) SlotID must support default initilization The return of SlotID++ will be stored with each slot for access
We use this type of lookup for slots because we need a way to access slots after the vectors iterators have been invalidated, but we need to do this quickly.
To accomplish this we use a simple linear search if the container contains less than 4 elements Otherwise we use std::lower_bound to quickly locate the slot with this ID in the vector This requires the vector to be sorted with lower IDs (older slots) first
Because generally slots aren't removed or queried nearly as much as they are emitted Applications will see huge performance gains over using a list or a vector of shared_ptr's due to the memory being contigious. Additions are pretty snappy in most cases because we don't need to make allocations for every slot, only when we've exceeded our underlying vectors capacity
In multithreaded applications it's reccomended that SlotIDGenerator be an atomic type or use mutexes to syncronize.
This would be better with some sort of Optional type
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::allocator_type = typename std::allocator_traits<Allocator>::template rebind_traits<slot>::allocator_type |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::callback = typename slot::callback |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::const_iterator = typename container_type::const_iterator |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::const_reference = typename container_type::const_reference |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::container_type = std::vector<slot, allocator_type> |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::iterator = typename container_type::iterator |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::pointer = typename container_type::pointer |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::reference = typename container_type::reference |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::size_type = typename container_type::size_type |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::slot = basic_slot<T, slot_id> |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::slot_id = decltype(slot_id_helper(std::declval<IDGenerator>())) |
using slimsig::slot_list< T, IDGenerator, FlagType, Allocator >::value_type = typename container_type::value_type |
|
inline |
|
inline |
|
default |
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |