diff options
Diffstat (limited to 'mempool/README.md')
-rw-r--r-- | mempool/README.md | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/mempool/README.md b/mempool/README.md index ed2935e..7eb950e 100644 --- a/mempool/README.md +++ b/mempool/README.md | |||
@@ -1,20 +1,15 @@ | |||
1 | # Mempool | 1 | # Mempool |
2 | 2 | ||
3 | A memory pool implementation. | 3 | A memory pool of fixed-sized blocks with O(1) allocation and deallocation. |
4 | 4 | ||
5 | Each block in the pool is tagged with a boolean value that indicates whether the | 5 | Each block in the pool is tagged with a boolean value that indicates whether the |
6 | block is free or in use. The allocator otherwise maintains little additional | 6 | block is free or in use, as well as a pointer to the next free/used block. |
7 | information. Therefore, some operations have linear-time complexity. | 7 | Blocks thus form two lists, a free list and a used list. The allocator |
8 | Specifically: | 8 | maintains the two lists when allocating/deallocating blocks. |
9 | 9 | ||
10 | - Allocating a block scans the pool for the next free block in linear time. | 10 | The allocator's internal data is stored separately from the block data so that |
11 | - Freeing a block runs in constant time. | 11 | the data remains tightly packed. |
12 | - Iterating over the pool's used blocks is linear over the number of blocks in | ||
13 | the pool, as opposed to just the number of used blocks. | ||
14 | 12 | ||
15 | The allocator's internal data is also stored separately from the main array of | 13 | Free blocks in the mempool always remain zeroed out for convenience of |
16 | blocks so that the block data remains tightly packed. | 14 | programming and debugging. If the application's data structures are valid when |
17 | 15 | zeroed out, then they do not need to be explicitly initialized. | |
18 | For convenience of programming and debugging, free blocks in the mempool always | ||
19 | remain zeroed out. If your data structures are valid when zeroed out, then you | ||
20 | do not need to explicitly initialize them. | ||