OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
heavyai::allocator::detail::FastAllocator< T > Class Template Reference

#include <FastAllocator.h>

+ Inheritance diagram for heavyai::allocator::detail::FastAllocator< T >:
+ Collaboration diagram for heavyai::allocator::detail::FastAllocator< T >:

Public Member Functions

 FastAllocator ()
 
 FastAllocator (T *buffer, size_t capacity)
 
 FastAllocator (FastAllocator const &)=delete
 
 FastAllocator (FastAllocator &&)=delete
 
FastAllocatoroperator= (FastAllocator const &)=delete
 
FastAllocatoroperator= (FastAllocator &&rhs)
 
T * allocate (size_t const n)
 
size_t available () const
 
size_t capacity () const
 
- Public Member Functions inherited from SimpleAllocator
virtual ~SimpleAllocator ()=default
 

Protected Member Functions

void reset ()
 

Protected Attributes

T * buffer_
 
size_t capacity_
 
size_t size_
 
std::mutex mutex_
 

Detailed Description

template<typename T>
class heavyai::allocator::detail::FastAllocator< T >

Definition at line 48 of file FastAllocator.h.

Constructor & Destructor Documentation

template<typename T >
heavyai::allocator::detail::FastAllocator< T >::FastAllocator ( T *  buffer,
size_t  capacity 
)
inline
template<typename T >
heavyai::allocator::detail::FastAllocator< T >::FastAllocator ( FastAllocator< T > const &  )
delete
template<typename T >
heavyai::allocator::detail::FastAllocator< T >::FastAllocator ( FastAllocator< T > &&  )
delete

Member Function Documentation

template<typename T >
T* heavyai::allocator::detail::FastAllocator< T >::allocate ( size_t const  n)
inlinevirtual

Implements SimpleAllocator.

Definition at line 65 of file FastAllocator.h.

References heavyai::allocator::detail::FastAllocator< T >::available(), heavyai::allocator::detail::FastAllocator< T >::buffer_, heavyai::allocator::detail::FastAllocator< T >::capacity_, CHECK, heavyai::allocator::detail::FastAllocator< T >::mutex_, anonymous_namespace{Utm.h}::n, heavyai::allocator::detail::outOfMemoryError(), heavyai::allocator::detail::FastAllocator< T >::size_, and heavydb.dtypes::T.

65  {
66  CHECK(n);
67  std::lock_guard<std::mutex> lock_guard(mutex_);
68  if (n <= available()) {
69  T* const ptr = buffer_ + size_;
70  size_ += n;
71  return ptr;
72  }
74  }
std::lock_guard< T > lock_guard
#define CHECK(condition)
Definition: Logger.h:291
constexpr double n
Definition: Utm.h:38
std::runtime_error outOfMemoryError(size_t n, size_t remaining, size_t capacity)
Definition: FastAllocator.h:36

+ Here is the call graph for this function:

template<typename T >
size_t heavyai::allocator::detail::FastAllocator< T >::available ( ) const
inline

Definition at line 76 of file FastAllocator.h.

References heavyai::allocator::detail::FastAllocator< T >::capacity_, and heavyai::allocator::detail::FastAllocator< T >::size_.

Referenced by heavyai::allocator::detail::FastAllocator< T >::allocate().

76 { return capacity_ - size_; } // number of available elements

+ Here is the caller graph for this function:

template<typename T >
size_t heavyai::allocator::detail::FastAllocator< T >::capacity ( ) const
inline

Definition at line 77 of file FastAllocator.h.

References heavyai::allocator::detail::FastAllocator< T >::capacity_.

77 { return capacity_; } // number of reserved elements
template<typename T >
FastAllocator& heavyai::allocator::detail::FastAllocator< T >::operator= ( FastAllocator< T > const &  )
delete

Member Data Documentation

template<typename T >
std::mutex heavyai::allocator::detail::FastAllocator< T >::mutex_
mutableprotected

The documentation for this class was generated from the following file: