17 namespace InferenceEngine {
22 class PreAllocator :
public IAllocator {
27 PreAllocator(
void* ptr,
size_t bytes_size): _actualData(ptr), _sizeInBytes(bytes_size) {}
32 void*
lock(
void* handle, LockOp = LOCK_FOR_WRITE) noexcept
override {
33 if (handle != _actualData) {
41 void unlock(
void*) noexcept
override {}
48 void*
alloc(
size_t size) noexcept
override {
49 if (size <= _sizeInBytes) {
59 bool free(
void*) noexcept
override {
67 void Release() noexcept
override {
72 virtual ~PreAllocator() =
default;
82 std::shared_ptr<IAllocator> make_pre_allocator(T* ptr,
size_t size) {
83 return shared_from_irelease(
new PreAllocator(ptr, size *
sizeof(T)));
virtual void * lock(void *handle, LockOp op=LOCK_FOR_WRITE) noexcept=0
Maps handle to heap memory accessible by any memory manipulation routines.
virtual bool free(void *handle) noexcept=0
Releases the handle and all associated memory resources which invalidates the handle.
virtual void * alloc(size_t size) noexcept=0
Allocates memory.
virtual void unlock(void *handle) noexcept=0
Unmaps memory by handle with multiple sequential mappings of the same handle.
A header file that provides Allocator interface.
A header file for the main Inference Engine exception.
handle_t handle(char const *name)
Create annotation handle with a given name.
Definition: itt.hpp:77