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