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