]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/PagePool.h
4 #ifndef SQUID_IPC_MEM_PAGE_POOL_H
5 #define SQUID_IPC_MEM_PAGE_POOL_H
7 #include "ipc/mem/Page.h"
8 #include "ipc/mem/PageStack.h"
9 #include "ipc/mem/Pointer.h"
17 /// Atomic container of shared memory pages. Implemented using a collection of
18 /// Segments, each with a PageStack index of free pages. All pools must be
19 /// created by a single process.
23 typedef Ipc::Mem::Owner
<PageStack
> Owner
;
25 static Owner
*Init(const char *const id
, const unsigned int capacity
, const size_t pageSize
);
27 PagePool(const char *const id
);
29 unsigned int capacity() const { return pageIndex
->capacity(); }
30 size_t pageSize() const { return pageIndex
->pageSize(); }
31 /// lower bound for the number of free pages
32 unsigned int size() const { return pageIndex
->size(); }
33 /// approximate number of shared memory pages used now
34 size_t level() const { return capacity() - size(); }
35 /// approximate number of shared memory pages used now for given purpose
36 size_t level(const int purpose
) const;
38 /// sets page ID and returns true unless no free pages are found
39 bool get(const PageId::Purpose purpose
, PageId
&page
);
40 /// makes identified page available as a free page to future get() callers
41 void put(PageId
&page
);
42 /// converts page handler into a temporary writeable shared memory pointer
43 char *pagePointer(const PageId
&page
);
46 Ipc::Mem::Pointer
<PageStack
> pageIndex
; ///< free pages index
47 /// number of shared memory pages used now for each purpose
48 Atomic::Word
*const theLevels
;
49 char *const theBuf
; ///< pages storage
56 #endif // SQUID_IPC_MEM_PAGE_POOL_H