7#ifndef OCL_CORE_ALLOCATOR_OP
8#define OCL_CORE_ALLOCATOR_OP
10#include <ocl/detail/config.hpp>
11#include <ocl/detail/alloc/config.hpp>
24 using pointer =
void*;
26 boost::source_location loc_;
29 inline void throw_bad_alloc(bad_alloc_traits::pointer p,
const boost::source_location& loc = BOOST_CURRENT_LOCATION)
41 template <
typename Type>
45 using pointer_type = Type*;
46 using const_pointer_type =
const Type*;
47 using pointer = Type*;
48 using const_pointer =
const Type*;
49 using mutex_type = std::mutex;
50 using lock_type = std::scoped_lock<mutex_type>;
56 auto single_alloc() -> pointer_type
62 auto array_alloc() -> pointer_type
64 static_assert(N > 0,
"N == 0, whereas N shall be greater than zero.");
68 template <
typename... VarType>
69 auto var_alloc(VarType&&... args) -> pointer_type
71 return new type{std::forward<VarType>(args)...};
75 template <
typename Type>
78 using pointer_type = Type*;
79 using const_pointer_type =
const Type*;
84 auto operator()(pointer_type t,
const bool array_delete =
false) ->
void
97 template <
typename Type>
101 template <
typename RetType,
typename AllocNew,
typename AllocDelete>
111 using size_type = std::size_t;
112 using type = RetType;
114 template <
typename... VarType>
115 auto construct_var(VarType&&... args)
117 static AllocNew alloc;
118 typename AllocNew::lock_type lt{alloc.m_};
119 return std::shared_ptr<type>(alloc.template var_alloc<VarType...>(std::forward<VarType...>(args)...), AllocDelete{});
122 template <
size_type N>
123 auto construct_array()
125 static AllocNew alloc;
126 typename AllocNew::lock_type lt{alloc.m_};
127 return std::shared_ptr<type>(alloc.template array_alloc<N>(), AllocDelete{});
131 template <
typename Type>
Allocator operations structure. Takes care of memory mgmt within a pool.
Definition allocator_fwd.hpp:103
Memory allocator for OCL support.
Definition allocator_fwd.hpp:16
Definition allocator_fwd.hpp:23
Definition allocator_fwd.hpp:77
Definition allocator_fwd.hpp:43