density
C++11 library for paged memory management, function queues, heterogeneous queues and lifo memory management
|
Classes | |
struct | add_cv_qual |
class | basic_default_allocator |
class | conc_function_queue |
class | conc_heter_queue |
struct | cv_qual_of |
class | default_busy_wait |
class | dynamic_reference |
class | f_alignment |
class | f_copy_assign |
class | f_copy_construct |
class | f_default_construct |
class | f_destroy |
class | f_equal |
class | f_hash |
class | f_istream |
class | f_less |
class | f_move_assign |
struct | f_move_construct |
struct | f_none |
class | f_ostream |
class | f_rtti |
class | f_size |
struct | feature_list |
class | function_queue |
struct | has_features |
class | heter_queue |
struct | is_dynamic_reference |
class | lf_function_queue |
class | lf_heter_queue |
class | lifo_allocator |
class | lifo_array |
class | lifo_buffer |
class | runtime_type |
class | sp_function_queue |
class | sp_heter_queue |
Typedefs | |
using | default_allocator = basic_default_allocator< default_page_capacity > |
using | data_stack_underlying_allocator = basic_default_allocator< default_page_capacity > |
template<typename TYPE > | |
using | optional = builtin_optional< TYPE > |
template<typename TYPE , cv_qual CV> | |
using | add_cv_qual_t = typename add_cv_qual< TYPE, CV >::type |
template<typename RUNTIME_TYPE = runtime_type<>> | |
using | const_dynamic_reference = dynamic_reference< RUNTIME_TYPE, cv_qual::const_qual > |
template<typename RUNTIME_TYPE = runtime_type<>> | |
using | volatile_dynamic_reference = dynamic_reference< RUNTIME_TYPE, cv_qual::volatile_qual > |
template<typename RUNTIME_TYPE = runtime_type<>> | |
using | const_volatile_dynamic_reference = dynamic_reference< RUNTIME_TYPE, cv_qual::const_volatile_qual > |
using | default_type_features = feature_list< f_size, f_alignment, f_copy_construct, f_move_construct, f_rtti, f_destroy > |
Enumerations | |
enum | concurrency_cardinality { concurrency_single, concurrency_multiple } |
enum | consistency_model { consistency_relaxed, consistency_sequential } |
enum | progress_guarantee { progress_blocking, progress_obstruction_free, progress_lock_free, progress_wait_free } |
enum | function_type_erasure { function_standard_erasure, function_manual_clear } |
enum | cv_qual { no_qual = 0, const_qual = 1, volatile_qual = 2, const_volatile_qual = 3 } |
Functions | |
constexpr bool | is_power_of_2 (size_t i_number) noexcept |
bool | address_is_aligned (const void *i_address, size_t i_alignment) noexcept |
template<typename UINT > | |
bool | uint_is_aligned (UINT i_uint, UINT i_alignment) noexcept |
void * | address_add (void *i_address, size_t i_offset) noexcept |
const void * | address_add (const void *i_address, size_t i_offset) noexcept |
void * | address_sub (void *i_address, size_t i_offset) noexcept |
const void * | address_sub (const void *i_address, size_t i_offset) noexcept |
uintptr_t | address_diff (const void *i_end_address, const void *i_start_address) noexcept |
void * | address_lower_align (void *i_address, size_t i_alignment) noexcept |
const void * | address_lower_align (const void *i_address, size_t i_alignment) noexcept |
void * | address_lower_align (void *i_address, size_t i_alignment, size_t i_alignment_offset) noexcept |
const void * | address_lower_align (const void *i_address, size_t i_alignment, size_t i_alignment_offset) noexcept |
void * | address_upper_align (void *i_address, size_t i_alignment) noexcept |
const void * | address_upper_align (const void *i_address, size_t i_alignment) noexcept |
template<typename UINT > | |
constexpr UINT | uint_upper_align (UINT i_uint, size_t i_alignment) noexcept |
template<typename UINT > | |
constexpr UINT | uint_lower_align (UINT i_uint, size_t i_alignment) noexcept |
void * | address_upper_align (void *i_address, size_t i_alignment, size_t i_alignment_offset) noexcept |
const void * | address_upper_align (const void *i_address, size_t i_alignment, size_t i_alignment_offset) noexcept |
void * | aligned_allocate (size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) |
void * | try_aligned_allocate (size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept |
void | aligned_deallocate (void *i_block, size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept |
constexpr bool | is_less_or_equal_cv_qualified (cv_qual i_first, cv_qual i_second) noexcept |
constexpr bool | is_less_cv_qualified (cv_qual i_first, cv_qual i_second) noexcept |
template<typename... FEATURES, typename = typename std::enable_if<has_features<feature_list<FEATURES...>, f_istream>::value>::type> | |
std::istream & | operator>> (std::istream &i_source_stream, const dynamic_reference< runtime_type< FEATURES... >> &i_ptr) |
template<typename... FEATURES, typename = typename std::enable_if<has_features<feature_list<FEATURES...>, f_ostream>::value>::type> | |
std::ostream & | operator<< (std::ostream &i_dest_stream, const dynamic_reference< runtime_type< FEATURES... >> &i_ref) |
template<typename TYPE > | |
TYPE | raw_atomic_load (TYPE const *i_atomic, std::memory_order i_memory_order=std::memory_order_seq_cst) noexcept=delete |
template<typename TYPE > | |
void | raw_atomic_store (TYPE *i_atomic, TYPE i_value, std::memory_order i_memory_order=std::memory_order_seq_cst) noexcept=delete |
template<typename TYPE > | |
bool | raw_atomic_compare_exchange_strong (TYPE *i_atomic, TYPE *i_expected, TYPE i_desired, std::memory_order i_success, std::memory_order i_failure) noexcept=delete |
template<typename TYPE > | |
bool | raw_atomic_compare_exchange_weak (TYPE *i_atomic, TYPE *i_expected, TYPE i_desired, std::memory_order i_success, std::memory_order i_failure) noexcept=delete |
template<typename TYPE > | |
bool | raw_atomic_compare_exchange_strong (TYPE *i_atomic, TYPE *i_expected, TYPE i_desired, std::memory_order i_memory_order=std::memory_order_seq_cst) noexcept |
template<typename TYPE > | |
bool | raw_atomic_compare_exchange_weak (TYPE *i_atomic, TYPE *i_expected, TYPE i_desired, std::memory_order i_memory_order=std::memory_order_seq_cst) noexcept |
Variables | |
constexpr char | version [] = "2.0.0" |
constexpr size_t | destructive_interference_size = 64 |
constexpr size_t | default_page_capacity = 1024 * 64 |
constexpr bool | enable_relaxed_atomics = false |
namespace density
Specialization of basic_default_allocator that uses density::default_page_capacity as page capacity.
Allocator type the data stack is built upon. It must satisfy the requirements of both UntypedAllocator and PagedAllocator
using optional = builtin_optional<TYPE> |
Alias to an implementation of optional. By default a minimal implementation of optional is used, but it can be replaced by the C++17 standard one, if available.
using add_cv_qual_t = typename add_cv_qual<TYPE, CV>::type |
Adds a cv-qualification to a type. Alias for add_cv_qual.
Example:
using const_dynamic_reference = dynamic_reference<RUNTIME_TYPE, cv_qual::const_qual> |
Type alias template for the class template that sets the qv-qualification to cv_qual::const_qual.
using volatile_dynamic_reference = dynamic_reference<RUNTIME_TYPE, cv_qual::volatile_qual> |
Type alias template for the class template that sets the qv-qualification to cv_qual::volatile_qual.
using const_volatile_dynamic_reference = dynamic_reference<RUNTIME_TYPE, cv_qual::const_volatile_qual> |
Type alias template for the class template that sets the qv-qualification to cv_qual::const_volatile_qual.
using default_type_features = feature_list<f_size, f_alignment, f_copy_construct, f_move_construct, f_rtti, f_destroy> |
feature_list used by default by runtime_type
Specifies whether a set of functions actually support concurrency
enum consistency_model |
Specifies which guarantee is provided on the order in which actions on a data structure are observable.
enum progress_guarantee |
Specifies which guarantee an algorithm on a concurrent data struct provides about the progress and the completion of the work.
Members are sorted so that lower values specifies weaker guarantee. Progress guarantees are cumulative: the guarantee G provides all the guarantees less than G.
Dead locks and priority inversion may happen only in blocking algorithms.
See https://en.wikipedia.org/wiki/Non-blocking_algorithm.
Specifies a set of features provided by the built-in type erasure system for callable objects
|
strong |
|
noexcept |
Returns true whether the given unsigned integer number is a power of 2 (1, 2, 4, 8, ...)
i_number | must be > 0, otherwise the behavior is undefined |
|
inlinenoexcept |
Returns true whether the given address has the specified alignment
i_address | address to be checked |
i_alignment | must be > 0 and a power of 2 |
|
inlinenoexcept |
Returns true whether the given unsigned integer has the specified alignment
i_uint | integer to be checked |
i_alignment | must be > 0 and a power of 2 |
|
inlinenoexcept |
Adds an offset to a pointer.
i_address | source address |
i_offset | number to add to the address |
|
inlinenoexcept |
Adds an offset to a pointer.
i_address | source address |
i_offset | number to add to the address |
|
inlinenoexcept |
Subtracts an offset from a pointer
i_address | source address |
i_offset | number to subtract from the address |
|
inlinenoexcept |
Subtracts an offset from a pointer
i_address | source address |
i_offset | number to subtract from the address |
|
inlinenoexcept |
Computes the unsigned difference between two pointers. The first must be above or equal to the second.
i_end_address | first address |
i_start_address | second address |
|
inlinenoexcept |
Returns the biggest aligned address lesser than or equal to a given address
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
inlinenoexcept |
Returns the biggest aligned address lesser than or equal to a given address
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
inlinenoexcept |
Returns the biggest address lesser than the first parameter, such that i_address + i_alignment_offset is aligned
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2 |
i_alignment_offset | alignment offset |
|
inlinenoexcept |
Returns the biggest address lesser than the first parameter, such that i_address + i_alignment_offset is aligned
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2 |
i_alignment_offset | alignment offset |
|
inlinenoexcept |
Returns the smallest aligned address greater than or equal to a given address
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
inlinenoexcept |
Returns the smallest aligned address greater than or equal to a given address
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
noexcept |
Returns the smallest aligned integer greater than or equal to a given address
i_uint | integer to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
noexcept |
Returns the biggest aligned address lesser than or equal to a given address
i_uint | integer to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2. |
|
inlinenoexcept |
Returns the smallest address greater than the first parameter, such that i_address + i_alignment_offset is aligned
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2 |
i_alignment_offset | alignment offset |
|
inlinenoexcept |
Returns the smallest address greater than the first parameter, such that i_address + i_alignment_offset is aligned
i_address | address to be aligned |
i_alignment | alignment required from the pointer. It must be an integer power of 2 |
i_alignment_offset | alignment offset |
|
inline |
Uses the global operator new to allocate a memory block with at least the specified size and alignment
i_size | size of the requested memory block, in bytes |
i_alignment | alignment of the requested memory block, in bytes |
i_alignment_offset | offset of the block to be aligned, in bytes. The alignment is guaranteed only at i_alignment_offset from the beginning of the block. |
A violation of any precondition results in undefined behavior.
Throws: std::bad_alloc if the allocation fails
Progress guarantee: the same of the built-in operator new (usually blocking)
The content of the newly allocated block is undefined.
|
inlinenoexcept |
Uses the global operator new to try to allocate a memory block with at least the specified size and alignment. Returns nullptr in case of failure.
i_size | size of the requested memory block, in bytes |
i_alignment | alignment of the requested memory block, in bytes |
i_alignment_offset | offset of the block to be aligned, in bytes. The alignment is guaranteed only at i_alignment_offset from the beginning of the block. |
A violation of any precondition results in undefined behavior.
Throws: nothing
Progress guarantee: the same of the built-in operator new (usually blocking)
The content of the newly allocated block is undefined.
|
inlinenoexcept |
Deallocates a memory block allocated by aligned_allocate, using the global operator delete. After the call any access to the memory block results in undefined behavior.
i_block | block to deallocate, or nullptr. |
i_size | size of the block to deallocate, in bytes. |
i_alignment | alignment of the memory block. |
i_alignment_offset | offset of the alignment |
Throws: nothing
Progress guarantee: the same of the built-in operator delete (usually blocking)
If i_block is nullptr, the call has no effect.
|
noexcept |
Returns true if the first operand is less than or equal to the second one according to the partial ordering of cv qualifications.
Given two reference types T1 and T2, this function can be used to determine whether a variable of type T1 can be initialized with an expression of type T2:
Example:
Returns true if the first operand is less than the second one according to the partial ordering of cv qualifications.
Example:
|
inline |
Reads the target object of a dynamic_reference that supports the feature f_ostream from an std::istream. If the feature f_ostream is supported by the runtime_type, this function does not participate in overload in overload resolution. Note: the dynamic_reference must be bound to a valid target of the correct type before the function is called.
Example:
Throws: unspecified
|
inline |
Writes the target object of a dynamic_reference that supports the feature f_ostream to an std::ostream. If the feature f_ostream is supported by the runtime_type, this function does not participate in overload in overload resolution.
Example:
Throws: unspecified
|
deletenoexcept |
Similar to std::atomic_load but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
|
deletenoexcept |
Similar to std::atomic_store but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
|
deletenoexcept |
Similar to std::atomic_compare_exchange_strong but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
|
deletenoexcept |
Similar to std::atomic_compare_exchange_weak but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
|
noexcept |
Similar to std::atomic_compare_exchange_strong but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
|
noexcept |
Similar to std::atomic_compare_exchange_weak but operates on fundamental types. This function has a limited support: availability depends on the compiler, the target architecture, and the type of the variable.
Overloads not available are declared as deleted.
Compiler | Platform | Types |
---|---|---|
msc | x86 | uint32_t |
msc | x64 | uint32_t, uint64_t |
g++/clang | any | uintptr_t |
constexpr char version[] = "2.0.0" |
string decimal variant of DENSITY_VERSION. The length of this string may change between versions. Example of value: "7.240.22"
constexpr size_t destructive_interference_size = 64 |
Alignment used by some concurrent data structure to avoid false sharing of cache lines. It must be a power of 2.
This is a configuration variable, intended to be customized by the user of the library. The default value is 64.
If a C++17 compiler is available, this constant may be defined as std::hardware_destructive_interference_size.
constexpr size_t default_page_capacity = 1024 * 64 |
Capacity (in bytes) of the pages managed by density::default_allocator. Note: the actual usable size is slightly smaller. This constant must be a power of 2.
This is a configuration variable, intended to be customized by the user of the library. The default value is 1024 * 64.
constexpr bool enable_relaxed_atomics = false |
In this version of the library relaxed atomic operations are disabled. Concurrently data structures has been tested on x86-x64, but not on architectures with weak memory ordering. If you want to contribute to density, running the tests on other architectures, you can change this constant.