PoolChunked.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef _MEM_POOL_CHUNKED_H_
10#define _MEM_POOL_CHUNKED_H_
11
12#include "mem/Allocator.h"
13#include "splay.h"
14
15#define MEM_CHUNK_SIZE 4 * 4096 /* 16KB ... 4 * VM_PAGE_SZ */
16#define MEM_CHUNK_MAX_SIZE 256 * 1024 /* 2MB */
17
18class MemChunk;
19
22{
23public:
24 friend class MemChunk;
25 MemPoolChunked(const char *label, size_t obj_size);
26 ~MemPoolChunked() override;
28 void createChunk();
29 void *get();
30 void push(void *obj);
31
32 /* Mem::Allocator API */
33 size_t getStats(Mem::PoolStats &) override;
34 void setChunkSize(size_t) override;
35 bool idleTrigger(int) const override;
36 void clean(time_t) override;
37
38protected:
39 /* Mem::Allocator API */
40 void *allocate() override;
41 void deallocate(void *) override;
42
43public:
44 size_t chunk_size;
47 void *freeCache;
51};
52
55{
56public:
58 ~MemChunk();
59 void *freeList;
60 void *objCache;
64 time_t lastref;
66};
67
68#endif /* _MEM_POOL_CHUNKED_H_ */
69
int inuse_count
Definition: PoolChunked.h:61
time_t lastref
Definition: PoolChunked.h:64
MemChunk * next
Definition: PoolChunked.h:63
void * objCache
Definition: PoolChunked.h:60
MemChunk * nextFreeChunk
Definition: PoolChunked.h:62
MemPoolChunked * pool
Definition: PoolChunked.h:65
MemChunk(MemPoolChunked *pool)
Definition: PoolChunked.cc:104
void * freeList
Definition: PoolChunked.h:59
void createChunk()
Definition: PoolChunked.cc:226
void push(void *obj)
Definition: PoolChunked.cc:164
bool idleTrigger(int) const override
Definition: PoolChunked.cc:426
void convertFreeCacheToChunkFreeCache()
Definition: PoolChunked.cc:336
void * freeCache
Definition: PoolChunked.h:47
void * allocate() override
*alloc()
Definition: PoolChunked.cc:317
MemChunk * nextFreeChunk
Definition: PoolChunked.h:48
void deallocate(void *) override
freeOne(void *)
Definition: PoolChunked.cc:327
size_t getStats(Mem::PoolStats &) override
Definition: PoolChunked.cc:432
Splay< MemChunk * > allChunks
Definition: PoolChunked.h:50
void setChunkSize(size_t) override
Definition: PoolChunked.cc:267
~MemPoolChunked() override
Definition: PoolChunked.cc:299
MemPoolChunked(const char *label, size_t obj_size)
Definition: PoolChunked.cc:141
MemChunk * Chunks
Definition: PoolChunked.h:49
void clean(time_t) override
Definition: PoolChunked.cc:362
size_t chunk_size
Definition: PoolChunked.h:44
const char * label
brief description of objects returned by alloc()
Definition: Allocator.h:109

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors