ZGen
0.2.0
a linearization system for natural language.
|
#include <span_allocator.h>
Public Member Functions | |
SpanAllocator (int reserved_num_spans=1, int bucket_size=65535) | |
Span * | malloc () |
void | clear () |
void | pruge () |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SpanAllocator &allocator) |
Span allocator is a stacked-list for allocating memory for spans. The following graph illustrate the general structure for SpanAllocator.
buckets | v [ 0 ] -> [ 1 ] -> [ 2 ] ... [B-1] | v [ B ] -> [B+1] -> [B+2] ... [2*B-1] | v ... Each time there is not enough memory for spans in buckets, the buckets array, which is the header array, is reallocated, but the stacked-list is not reallocated. It guarentee that the allocated span's address is not modified.
ZGen::BestFirst::SpanAllocator::SpanAllocator | ( | int | reserved_num_spans = 1 , |
int | bucket_size = 65535 |
||
) |
Initialize the span allocator with the total number of spans, the size of each buckets.
[in] | num_spans | The total number of spans in the allocator. |
[in] | bucket_size | The number of elements in each buckets. |
void ZGen::BestFirst::SpanAllocator::clear | ( | ) |
Batchly clear all the spans in the Pool. The
Span * ZGen::BestFirst::SpanAllocator::malloc | ( | ) |
void ZGen::BestFirst::SpanAllocator::pruge | ( | ) |
Clear all the instance in pool.
|
friend |
Print the allocator information onto the stream, [Not Impl].
in/out] | os | |
[in] | allocator |