]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/mem/Pages.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / mem / Pages.h
CommitLineData
3e0ddf16 1/*
f6e9a3ee 2 * Copyright (C) 1996-2019 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
14namespace Ipc
15{
3e0ddf16 16
9199139f
AR
17namespace 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 23bool GetPage(const PageId::Purpose purpose, PageId &page);
3e0ddf16
AR
24
25/// makes identified page available as a free page to future GetPage() callers
56f8aa50 26void PutPage(PageId &page);
3e0ddf16
AR
27
28/// converts page handler into a temporary writeable shared memory pointer
8ed94021 29char *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
34size_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
38size_t PageLimit(const int purpose);
e0bdae60
DK
39
40/// approximate total number of shared memory pages used now
41size_t PageLevel();
42
551f8a18
DK
43/// approximate total number of shared memory pages used now for given purpose
44size_t PageLevel(const int purpose);
e0bdae60
DK
45
46/// approximate total number of shared memory pages we can allocate now
47inline 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
51inline 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
54size_t PageSize();
55
ea2cdeb6
DK
56/// claim the need for a number of pages for a given purpose
57void 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