Classes | Variables
vnl_alloc.h File Reference

Default node allocator. More...

#include <cstddef>
#include "vnl/vnl_export.h"

Go to the source code of this file.

Classes

class  vnl_alloc
 
union  vnl_alloc::obj
 
class  vnl_alloc::lock
 

Variables

constexpr int VNL_ALLOC_ALIGN = 8
 
constexpr std::size_t VNL_ALLOC_MAX_BYTES = 256
 
constexpr std::size_t VNL_ALLOC_NFREELISTS = VNL_ALLOC_MAX_BYTES/VNL_ALLOC_ALIGN
 

Detailed Description

Default node allocator.

Author
unknown

With a reasonable compiler, this should be roughly as fast as the original STL class-specific allocators, but with less fragmentation. Default_alloc_template parameters are experimental and MAY DISAPPEAR in the future. Clients should just use vcl_alloc for now.

Important implementation properties:

The first template parameter specifies whether more than one thread may use this allocator. It is safe to allocate an object from one instance of a default_alloc and deallocate it with another one. This effectively transfers its ownership to the second one. This may have undesirable effects on reference locality. The second parameter is unreferenced and serves only to allow the creation of multiple default_alloc instances.

Note that containers built on different allocator instances have different types, limiting the utility of this approach.

Definition in file vnl_alloc.h.

Variable Documentation

◆ VNL_ALLOC_ALIGN

constexpr int VNL_ALLOC_ALIGN = 8

Definition at line 40 of file vnl_alloc.h.

◆ VNL_ALLOC_MAX_BYTES

constexpr std::size_t VNL_ALLOC_MAX_BYTES = 256

Definition at line 41 of file vnl_alloc.h.

◆ VNL_ALLOC_NFREELISTS

constexpr std::size_t VNL_ALLOC_NFREELISTS = VNL_ALLOC_MAX_BYTES/VNL_ALLOC_ALIGN

Definition at line 42 of file vnl_alloc.h.