Go to the documentation of this file.
9 #ifndef SQUID_SRC_IPC_MEM_POINTER_H
10 #define SQUID_SRC_IPC_MEM_POINTER_H
24 template <
class Class>
28 static Owner *
New(
const char *
const id);
30 static Owner *
New(
const char *
const id,
const P1 &p1);
31 template <
class P1,
class P2>
32 static Owner *
New(
const char *
const id,
const P1 &p1,
const P2 &p2);
33 template <
class P1,
class P2,
class P3>
34 static Owner *
New(
const char *
const id,
const P1 &p1,
const P2 &p2,
const P3 &p3);
35 template <
class P1,
class P2,
class P3,
class P4>
36 static Owner *
New(
const char *
const id,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4);
38 static Owner *
Old(
const char *
const id);
46 explicit Owner(
const char *
const id);
47 Owner(
const char *
const id,
const off_t sharedSize);
60 template <
class Class>
67 explicit Object(
const char *
const id);
81 template <
class Class>
98 template <
class Class>
100 theSegment(id), theObject(nullptr)
102 theSegment.create(sharedSize);
103 Must(theSegment.mem());
106 template <
class Class>
108 theSegment(id), theObject(nullptr)
110 theSegment.open(
true);
111 Must(theSegment.mem());
114 template <
class Class>
121 template <
class Class>
125 auto owner =
new Owner(
id);
126 owner->theObject =
reinterpret_cast<Class*
>(owner->theSegment.mem());
127 Must(
static_cast<off_t
>(owner->theObject->sharedMemorySize()) <= owner->theSegment.size());
131 template <
class Class>
135 const off_t sharedSize = Class::SharedMemorySize();
136 Owner *
const owner =
new Owner(
id, sharedSize);
141 template <
class Class>
template <
class P1>
145 const off_t sharedSize = Class::SharedMemorySize(p1);
146 Owner *
const owner =
new Owner(
id, sharedSize);
151 template <
class Class>
template <
class P1,
class P2>
155 const off_t sharedSize = Class::SharedMemorySize(p1, p2);
156 Owner *
const owner =
new Owner(
id, sharedSize);
161 template <
class Class>
template <
class P1,
class P2,
class P3>
165 const off_t sharedSize = Class::SharedMemorySize(p1, p2, p3);
166 Owner *
const owner =
new Owner(
id, sharedSize);
171 template <
class Class>
template <
class P1,
class P2,
class P3,
class P4>
175 const off_t sharedSize = Class::SharedMemorySize(p1, p2, p3, p4);
176 Owner *
const owner =
new Owner(
id, sharedSize);
183 template <
class Class>
192 template <
class Class>
200 #define shm_new(Class) Ipc::Mem::Owner<Class>::New
201 #define shm_old(Class) Ipc::Mem::Object<Class>::Old
Object & operator=(const Object &)
Class * operator->() const
RefCount< Object< Class > > Base
Class * theObject
shared object
static Pointer< Class > Old(const char *const id)
Class * theObject
shared object
Segment theSegment
shared memory segment that holds the object
void * reserve(size_t chunkSize)
reserve and return the next chunk
Pointer(Object< Class > *const anObject=nullptr)
attaches to a shared memory segment with Class object owned by Owner
static Owner * Old(const char *const id)
attaches to the existing shared memory segment, becoming its owner
POSIX shared memory segment.
void open(const bool unlinkWhenDone)
Owner & operator=(const Owner &)
Object(const char *const id)
Segment theSegment
shared memory segment that holds the object
static Owner * New(const char *const id)
Owner(const char *const id)
Class & operator*() const
Class * object()
Raw access; handy to finalize initiatization, but avoid if possible.
const Class * getRaw() const