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