MySQL 5.6.14 Source Code Document
|
#include <semisync_master.h>
Classes | |
struct | Block |
Public Member Functions | |
TranxNodeAllocator (uint reserved_nodes) | |
TranxNode * | allocate_node () |
int | free_all_nodes () |
int | free_nodes_before (TranxNode *node) |
This class provides memory allocating and freeing methods for TranxNode. The main target is performance.
The pointer of the first node after 'last_node' in current_block is returned. current_block will move to the next free Block when all nodes of it are in use. A new Block is allocated and is put into the rear of the Block link table if no Block is free.
The list starts up empty (ie, there is no allocated Block).
After some nodes are freed, there probably are some free nodes before the sequence of the allocated nodes, but we do not reuse it. It is better to keep the allocated nodes are in the sequence, for it is more efficient for allocating and freeing TranxNode.
There are two methods for freeing nodes. They are free_all_nodes and free_nodes_before.
'A Block is free' means all of its nodes are free.
As all allocated nodes are in the sequence, 'Before one node' means all nodes before given node in the same Block and all Blocks before the Block which containing the given node. As such, all Blocks before the given one ('node') are free Block and moved into the rear of the Block link table. The Block containing the given 'node', however, is not. For at least the given 'node' is still in use. This will waste at most one Block, but it is more efficient.
Definition at line 72 of file semisync_master.h.
|
inline |
reserved_nodes | The number of reserved TranxNodes. It is used to set 'reserved_blocks' which can contain at least 'reserved_nodes' number of TranxNodes. When freeing memory, we will reserve at least reserved_blocks of Blocks not freed. |
Definition at line 82 of file semisync_master.h.
|
inline |
The pointer of the first node after 'last_node' in current_block is returned. current_block will move to the next free Block when all nodes of it are in use. A new Block is allocated and is put into the rear of the Block link table if no Block is free.
Definition at line 107 of file semisync_master.h.
|
inline |
All nodes are freed.
Definition at line 139 of file semisync_master.h.
|
inline |
All Blocks before the given 'node' are free Block and moved into the rear of the Block link table.
node | All nodes before 'node' will be freed |
Definition at line 155 of file semisync_master.h.