Fawkes API
Fawkes Development Version
|
#include <>>
Classes | |
struct | SharedMemID |
Shared memory identifier. More... | |
Public Member Functions | |
SharedMemoryRegistry (const char *name=0) | |
Constructor. More... | |
~SharedMemoryRegistry () | |
Destructor. More... | |
std::list< SharedMemoryRegistry::SharedMemID > | get_snapshot () const |
Get a snapshot of currently registered segments. More... | |
std::list< SharedMemoryRegistry::SharedMemID > | find_segments (const char *magic_token) const |
Find segments with particular magic token. More... | |
void | add_segment (int shmid, const char *magic_token) |
Register a segment. More... | |
void | remove_segment (int shmid) |
Remove segment. More... | |
Static Public Member Functions | |
static void | cleanup (const char *name=0) |
Cleanup existing shared memory segments. More... | |
Shared memory registry. This class opens a named POSIX shared memory segment, which contains one instance of the MemInfo struct. It is used to detect and maintain existing SysV IPC shared memory segments in a platform independent way. SysV IPC shared memory segments have some advanced functionality, for example reporting how many processes have attached to the segment. For the registry however, we are more interested in using a symbolic name which is the same for registry entries. Therefore, we use this here. The struct is protected by a lock implemented as a semaphore. Whenever a shared memory segment is created, it is registered to the registry so others can find it. On destruction, it is unregistered from the registry.
Definition at line 37 of file shm_registry.h.
fawkes::SharedMemoryRegistry::SharedMemoryRegistry | ( | const char * | name = 0 | ) |
Constructor.
name | name of the shared memory region. Must follow the rules set by shm_open(). If NULL defaults to "/fawkes-shmem-registry". |
Definition at line 64 of file shm_registry.cpp.
fawkes::SharedMemoryRegistry::~SharedMemoryRegistry | ( | ) |
Destructor.
Definition at line 127 of file shm_registry.cpp.
void fawkes::SharedMemoryRegistry::add_segment | ( | int | shmid, |
const char * | magic_token | ||
) |
Register a segment.
shmid | shared memory ID of the SysV IPC segment |
magic_token | magic token for the new segment |
Definition at line 198 of file shm_registry.cpp.
|
static |
Cleanup existing shared memory segments.
name | shared memory segment name |
Definition at line 142 of file shm_registry.cpp.
std::list< SharedMemoryRegistry::SharedMemID > fawkes::SharedMemoryRegistry::find_segments | ( | const char * | magic_token | ) | const |
Find segments with particular magic token.
magic_token | magic token to return IDs for |
Definition at line 175 of file shm_registry.cpp.
Referenced by fawkes::SharedMemory::exists().
std::list< SharedMemoryRegistry::SharedMemID > fawkes::SharedMemoryRegistry::get_snapshot | ( | ) | const |
Get a snapshot of currently registered segments.
Definition at line 152 of file shm_registry.cpp.
void fawkes::SharedMemoryRegistry::remove_segment | ( | int | shmid | ) |
Remove segment.
shmid | shared memory ID of the segment to remove. |
Definition at line 229 of file shm_registry.cpp.
Referenced by fawkes::SharedMemory::free().