]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/Pages.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / mem / Pages.h
1 /*
2 * $Id$
3 *
4 */
5
6 #ifndef SQUID_IPC_MEM_PAGES_H
7 #define SQUID_IPC_MEM_PAGES_H
8
9 #include "ipc/mem/Page.h"
10
11 namespace Ipc
12 {
13
14 namespace Mem
15 {
16
17 /* Single page manipulation */
18
19 /// sets page ID and returns true unless no free pages are found
20 bool GetPage(const PageId::Purpose purpose, PageId &page);
21
22 /// makes identified page available as a free page to future GetPage() callers
23 void PutPage(PageId &page);
24
25 /// converts page handler into a temporary writeable shared memory pointer
26 char *PagePointer(const PageId &page);
27
28
29 /* Limits and statistics */
30
31 /// the total number of shared memory pages that can be in use at any time
32 size_t PageLimit();
33
34 /// the total number of shared memory pages that can be in use at any
35 /// time for given purpose
36 size_t PageLimit(const int purpose);
37
38 /// approximate total number of shared memory pages used now
39 size_t PageLevel();
40
41 /// approximate total number of shared memory pages used now for given purpose
42 size_t PageLevel(const int purpose);
43
44 /// approximate total number of shared memory pages we can allocate now
45 inline size_t PagesAvailable() { return PageLimit() - PageLevel(); }
46
47 /// approximate total number of shared memory pages we can allocate
48 /// now for given purpose
49 inline size_t PagesAvailable(const int purpose) { return PageLimit(purpose) - PageLevel(purpose); }
50
51 /// returns page size in bytes; all pages are assumed to be the same size
52 size_t PageSize();
53
54 } // namespace Mem
55
56 } // namespace Ipc
57
58 #endif // SQUID_IPC_MEM_PAGES_H