]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/Page.h
Merged from upstream
[thirdparty/squid.git] / src / ipc / mem / Page.h
1 /*
2 */
3
4 #ifndef SQUID_IPC_MEM_PAGE_H
5 #define SQUID_IPC_MEM_PAGE_H
6
7 #if HAVE_IOSFWD
8 #include <iosfwd>
9 #endif
10
11 namespace Ipc
12 {
13
14 namespace Mem
15 {
16
17 /// Shared memory page identifier, address, or handler
18 class PageId
19 {
20 public:
21 PageId(): pool(0), number(0), purpose(maxPurpose) {}
22
23 /// true if and only if both critical components have been initialized
24 bool set() const { return pool && number; }
25
26 // safer than bool which would enable silent casts to int
27 typedef const uint32_t PageId::*SaferBool;
28 operator SaferBool() const { return set() ? &PageId::number : NULL; }
29
30 uint32_t pool; ///< page pool ID within Squid
31 // uint32_t segment; ///< memory segment ID within the pool; unused for now
32 uint32_t number; ///< page number within the segment
33
34 enum Purpose { cachePage, ioPage, maxPurpose };
35 Purpose purpose; ///< page purpose
36 };
37
38 /// writes page address (e.g., "sh_page5.3"), for debugging
39 std::ostream &operator <<(std::ostream &os, const PageId &page);
40
41 } // namespace Mem
42
43 } // namespace Ipc
44
45 #endif // SQUID_IPC_MEM_PAGE_H