A reference counted wrapper around fast allocated or malloced memory. More...
#include <I_IOBuffer.h>
Inherits RefCountObj.
Public Member Functions | |
int64_t | block_size () |
The size of the memory allocated by this IOBufferData. | |
void | dealloc () |
Frees the memory managed by this IOBufferData. | |
void | alloc (int64_t size_index, AllocType type=DEFAULT_ALLOC) |
Allocates memory and sets this IOBufferData to point to it. | |
char * | data () |
Provides access to the allocated memory. | |
operator char * () | |
Cast operator. | |
virtual void | free () |
Frees the IOBufferData object and its underlying memory. | |
IOBufferData () | |
Constructor. | |
Data Fields | |
int64_t | _size_index |
AllocType | _mem_type |
Type of allocation used for the managed memory. | |
char * | _data |
Points to the allocated memory. | |
const char * | _location |
A reference counted wrapper around fast allocated or malloced memory.
The IOBufferData class provides two basic services around a portion of allocated memory.
First, it is a reference counted object and ...
AllocType | Meaning |
NO_ALLOC | |
FAST_ALLOCATED | |
XMALLOCED | |
MEMALIGNED | |
DEFAULT_ALLOC | |
CONSTANT |
Definition at line 178 of file I_IOBuffer.h.
IOBufferData::IOBufferData | ( | ) | [inline] |
Constructor.
Initializes state for a IOBufferData object. Do not use this method. Use one of the functions with the 'new_' prefix instead.
Definition at line 271 of file I_IOBuffer.h.
TS_INLINE void IOBufferData::alloc | ( | int64_t | size_index, | |
AllocType | type = DEFAULT_ALLOC | |||
) |
Allocates memory and sets this IOBufferData to point to it.
Allocates memory according to the size_index and type parameters. Any previously allocated memory pointed to by this IOBufferData is deallocated.
size_index | ||
type | of allocation to use; see remarks section. |
Definition at line 281 of file P_IOBuffer.h.
References _data, _location, _mem_type, ats_malloc(), ats_memalign(), BUFFER_SIZE_FOR_XMALLOC, BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED, BUFFER_SIZE_INDEX_IS_XMALLOCED, dealloc(), DEFAULT_ALLOC, index_to_buffer_size(), ioBufAllocator, and MEMALIGNED.
Referenced by new_IOBufferData_internal().
TS_INLINE int64_t IOBufferData::block_size | ( | ) |
The size of the memory allocated by this IOBufferData.
Calculates the amount of memory allocated by this IOBufferData.
Definition at line 195 of file P_IOBuffer.h.
References index_to_buffer_size().
Referenced by RamCacheLRU::put(), RamCacheCLFUS::put(), and IOBufferBlock::set().
char* IOBufferData::data | ( | ) | [inline] |
Provides access to the allocated memory.
Returns the address of the allocated memory handled by this IOBufferData.
Definition at line 218 of file I_IOBuffer.h.
References _data.
Referenced by RamCacheCLFUS::get(), and RamCacheCLFUS::put().
TS_INLINE void IOBufferData::dealloc | ( | ) |
Frees the memory managed by this IOBufferData.
Deallocates the memory previously allocated by this IOBufferData object. It frees the memory pointed to by '_data' according to the '_mem_type' and '_size_index' members.
Definition at line 312 of file P_IOBuffer.h.
References _data, _location, _mem_type, ats_free(), BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED, BUFFER_SIZE_INDEX_IS_XMALLOCED, DEFAULT_ALLOC, free(), Allocator::free_void(), ioBufAllocator, and MEMALIGNED.
TS_INLINE void IOBufferData::free | ( | ) | [virtual] |
Frees the IOBufferData object and its underlying memory.
Deallocates the memory managed by this IOBufferData and then frees itself. You should not use this object or reference after this call.
Reimplemented from RefCountObj.
Definition at line 338 of file P_IOBuffer.h.
References dealloc(), ioDataAllocator, this_thread(), and THREAD_FREE.
Referenced by dealloc().
IOBufferData::operator char * | ( | ) | [inline] |
Cast operator.
Provided as a convenience, the cast to a char* applied to the IOBufferData returns the address of the memory handled by the IOBuffer data. In this manner, objects of this class can be used as parameter to functions requiring a char*.
Definition at line 230 of file I_IOBuffer.h.
References _data.
char* IOBufferData::_data |
Points to the allocated memory.
This member stores the address of the allocated memory. You should not modify its value directly, instead use the alloc or dealloc methods.
Definition at line 260 of file I_IOBuffer.h.
Referenced by alloc(), data(), dealloc(), new_IOBufferData_internal(), and operator char *().
const char* IOBufferData::_location |
Definition at line 263 of file I_IOBuffer.h.
Referenced by alloc(), dealloc(), and new_IOBufferData_internal().
Type of allocation used for the managed memory.
Stores the type of allocation used for the memory currently managed by the IOBufferData object. Do not set or modify this value directly. Instead use the alloc or dealloc methods.
Definition at line 252 of file I_IOBuffer.h.
Referenced by alloc(), dealloc(), and RamCacheCLFUS::get().
int64_t IOBufferData::_size_index |
Definition at line 243 of file I_IOBuffer.h.
Referenced by new_IOBufferData_internal().