]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/mem/Page.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / mem / Page.h
CommitLineData
bbc27441 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.
7 */
8
3e0ddf16
AR
9#ifndef SQUID_IPC_MEM_PAGE_H
10#define SQUID_IPC_MEM_PAGE_H
11
3e0ddf16 12#include <iosfwd>
3e0ddf16 13
9199139f
AR
14namespace Ipc
15{
3e0ddf16 16
9199139f
AR
17namespace Mem
18{
3e0ddf16
AR
19
20/// Shared memory page identifier, address, or handler
9199139f
AR
21class PageId
22{
3e0ddf16 23public:
551f8a18 24 PageId(): pool(0), number(0), purpose(maxPurpose) {}
3e0ddf16 25
99b19610
AR
26 /// true if and only if both critical components have been initialized
27 bool set() const { return pool && number; }
28
29 // safer than bool which would enable silent casts to int
30 typedef const uint32_t PageId::*SaferBool;
31 operator SaferBool() const { return set() ? &PageId::number : NULL; }
8ed94021 32
56f8aa50
DK
33 uint32_t pool; ///< page pool ID within Squid
34 // uint32_t segment; ///< memory segment ID within the pool; unused for now
3e0ddf16 35 uint32_t number; ///< page number within the segment
551f8a18
DK
36
37 enum Purpose { cachePage, ioPage, maxPurpose };
38 Purpose purpose; ///< page purpose
3e0ddf16
AR
39};
40
41/// writes page address (e.g., "sh_page5.3"), for debugging
42std::ostream &operator <<(std::ostream &os, const PageId &page);
43
44} // namespace Mem
45
46} // namespace Ipc
47
48#endif // SQUID_IPC_MEM_PAGE_H
f53969cc 49