Go to the documentation of this file.
9 #ifndef SQUID_IPC_MEM_POINTER_H
10 #define SQUID_IPC_MEM_POINTER_H
24 template <
class Class>
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);
46 explicit Owner(
const char *
const id);
47 Owner(
const char *
const id,
const off_t sharedSize);
57 template <
class Class>
class Pointer;
60 template <
class Class>
67 explicit Object(
const char *
const id);
81 template <
class Class>
98 template <
class Class>
100 theSegment(id), theObject(
NULL)
106 template <
class Class>
108 theSegment(id), theObject(nullptr)
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
static Owner * New(const char *const id, const P1 &p1, const P2 &p2)
Object & operator=(const Object &)
static Owner * New(const char *const id, const P1 &p1, const P2 &p2, const P3 &p3)
Class * operator->() const
RefCount< Object< Class > > Base
Class * theObject
shared object
Owner(const char *const id, const off_t sharedSize)
static Pointer< Class > Old(const char *const id)
void * mem()
pointer to the next chunk
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=NULL)
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.
static Owner * New(const char *const id, const P1 &p1)
void open(const bool unlinkWhenDone)
off_t size()
shared memory segment size
void create(const off_t aSize)
Create a new shared memory segment. Unlinks the segment on destruction.
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, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
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