21 #ifndef G_SHARED_MEMORY__H
22 #define G_SHARED_MEMORY__H
44 G_EXCEPTION( Error ,
"shared memory error" ) ;
93 static std::string
delete_(
const std::string & name ,
bool control_segment ) ;
107 static std::string
osName(
const std::string & name ) ;
120 bool remap(
size_t ,
bool may_move ,
bool no_throw =
false ) ;
127 static void help(
const std::string & ) ;
131 static void prefix(
const std::string & ) ;
137 static std::string
prefix() ;
140 static void filetext(
const std::string & ) ;
143 static std::vector<std::string>
list(
bool os_names =
false ) ;
155 std::string m_unlink_name ;
160 private: Imp(
const Imp & ) ;
161 private:
void operator=(
const Imp & ) ;
167 void init(
const std::string & ,
int ,
size_t ,
int ,
bool ) ;
168 static void createMarker(
const std::string & ) ;
169 static void deleteMarker(
const std::string & ) ;
170 static void deleteMarker(
SignalSafe ,
const char * ) ;
171 static void listImp( std::vector<std::string> & ,
const std::string & ,
const std::string & ,
bool ) ;
void * ptr() const
Returns the mapped address.
static void help(const std::string &)
Sets some error-message help text for the case when named shared memory cannot be created because it ...
An empty structure that is used to indicate a signal-safe, reentrant implementation.
static std::string prefix()
Returns the prefix, as set by by a call to the other overload.
void inherit()
Marks fd() as inherited across exec() ie. no-close-on-exec.
static std::string delete_(const std::string &name, bool control_segment)
Unlinks the segment from the filesystem.
static std::vector< std::string > list(bool os_names=false)
Returns a list of possible control segment names.
int fd() const
Returns the file descriptor. Returns -1 for anonymous segments.
Overload discriminator for G::SharedMemory.
~SharedMemory()
Destructor.
bool remap(size_t, bool may_move, bool no_throw=false)
Resizes and remaps the shared memory.
static void trap(SignalSafe, const char *os_name, void(*fn)(SignalSafe, void *))
An exit handler that calls the user's function on the shared memory contents.
A POSIX shared memory class.
SharedMemory(size_t size)
Constructor for a new anonymous segment, typically used across a fork().
void unlink()
Unlinks the segment from the filesystem.
static void cleanup(SignalSafe, const char *os_name, void(*fn)(SignalSafe, void *))
An exit handler that unlinks the named shared memory segment and calls the user's function for the me...
static std::string osName(const std::string &name)
Converts the segment name to an internal form that can be passed to cleanup() or trap().
static void filetext(const std::string &)
Sets some help text that gets written into the placeholder files.
size_t size() const
Returns the segment size. This is affected by remap().