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