class ov::Allocator¶
Overview¶
Wraps allocator implementation to provide safe way to store allocater loaded from shared library And constructs default based on new
delete
c++ calls allocator if created without parameters Accepts any std::pmr::memory_resource like allocator. More…
#include <allocator.hpp>
class Allocator
{
public:
// structs
struct Base;
template <typename A>
struct Impl;
// construction
Allocator();
Allocator(const Allocator& other);
Allocator(Allocator&& other);
Allocator(const AllocatorImpl::Ptr& impl);
template <
typename A,
typename std::enable_if<!std::is_convertible<A, AllocatorImpl::Ptr>::value&&!std::is_same<typename std::decay<A>::type, Allocator>::value&&!std::is_abstract<typename std::decay<A>::type>::value&&!std::is_convertible<typename std::decay<A>::type, std::shared_ptr<Base>>::value, bool>::type = true
>
Allocator(A&& a);
// methods
Allocator& operator = (const Allocator& other);
Allocator& operator = (Allocator&& other);
OPENVINO_SUPPRESS_DEPRECATED_END void \* allocate(
const size_t bytes,
const size_t alignment = alignof(max_align_t)
);
void deallocate(
void \* ptr,
const size_t bytes = 0,
const size_t alignment = alignof(max_align_t)
);
bool operator == (const Allocator& other) const;
bool operator ! () const;
operator bool () const;
};
Detailed Documentation¶
Wraps allocator implementation to provide safe way to store allocater loaded from shared library And constructs default based on new
delete
c++ calls allocator if created without parameters Accepts any std::pmr::memory_resource like allocator.
Construction¶
Allocator()
Default constructor.
Allocator(const Allocator& other)
Default copy constructor.
Parameters:
other |
other Allocator object |
Allocator(Allocator&& other)
Default move constructor.
Parameters:
other |
other Allocator object |
Allocator(const AllocatorImpl::Ptr& impl)
Constructs Allocator from the initialized std::shared_ptr.
Parameters:
impl |
Initialized shared pointer |
template <
typename A,
typename std::enable_if<!std::is_convertible<A, AllocatorImpl::Ptr>::value&&!std::is_same<typename std::decay<A>::type, Allocator>::value&&!std::is_abstract<typename std::decay<A>::type>::value&&!std::is_convertible<typename std::decay<A>::type, std::shared_ptr<Base>>::value, bool>::type = true
>
Allocator(A&& a)
Initialize allocator using any allocator like object.
Parameters:
A |
Type of allocator |
a |
allocator object |
Methods¶
Allocator& operator = (const Allocator& other)
Default copy assignment operator.
Parameters:
other |
other Allocator object |
Returns:
reference to the current object
Allocator& operator = (Allocator&& other)
Default move assignment operator.
Parameters:
other |
other Allocator object |
Returns:
reference to the current object
OPENVINO_SUPPRESS_DEPRECATED_END void \* allocate(
const size_t bytes,
const size_t alignment = alignof(max_align_t)
)
Allocates memory.
Parameters:
bytes |
The size in bytes at least to allocate |
alignment |
The alignment of storage |
if specified size and alignment is not supported |
Returns:
Handle to the allocated resource
void deallocate(
void \* ptr,
const size_t bytes = 0,
const size_t alignment = alignof(max_align_t)
)
Releases the handle and all associated memory resources which invalidates the handle.
Parameters:
ptr |
The handle to free |
bytes |
The size in bytes that was passed into allocate() method |
alignment |
The alignment of storage that was passed into allocate() method |
bool operator == (const Allocator& other) const
Compares with other Allocator.
Parameters:
other |
Other instance of allocator |
Returns:
true
if and only if memory allocated from one Allocator can be deallocated from the other and vice versa
bool operator ! () const
Checks if current Allocator object is not initialized.
Returns:
true
if current Allocator object is not initialized, false
- otherwise
operator bool () const
Checks if current Allocator object is initialized.
Returns:
true
if current Allocator object is initialized, false
- otherwise