]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/Pages.h
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_IPC_MEM_PAGES_H
10 #define SQUID_IPC_MEM_PAGES_H
12 #include "ipc/mem/Page.h"
20 /* Single page manipulation */
22 /// sets page ID and returns true unless no free pages are found
23 bool GetPage(const PageId::Purpose purpose
, PageId
&page
);
25 /// makes identified page available as a free page to future GetPage() callers
26 void PutPage(PageId
&page
);
28 /// converts page handler into a temporary writeable shared memory pointer
29 char *PagePointer(const PageId
&page
);
31 /* Limits and statistics */
33 /// the total number of shared memory pages that can be in use at any time
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
);
40 /// approximate total number of shared memory pages used now
43 /// approximate total number of shared memory pages used now for given purpose
44 size_t PageLevel(const int purpose
);
46 /// approximate total number of shared memory pages we can allocate now
47 inline size_t PagesAvailable() { return PageLimit() - PageLevel(); }
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
); }
53 /// returns page size in bytes; all pages are assumed to be the same size
56 /// claim the need for a number of pages for a given purpose
57 void NotePageNeed(const int purpose
, const int count
);
63 #endif // SQUID_IPC_MEM_PAGES_H