A class for operation on a (one) shared memory segment. More...
#include <libppbase/base/SharedMemory.h>
Public Types | |
| enum | openFlags { ofCreate = 0x01, ofExclusive = 0x02 } |
Open flags for open(). More... | |
Public Member Functions | |
| SharedMemory () | |
| Creates an empty object. | |
| ~SharedMemory () | |
| Unmaps the shared memory segment if it is still mapped. | |
| void | close () |
| Closes the shared memory segment. | |
| void | destroy () |
| Destroys the shared memory segment. | |
| void * | getAddr () const |
| Gets the start address of the shared memory segment in this process. | |
| void * | map (bool rw=true, void *addr=NULL) |
| Maps the shared memory segment into the address space of this process. | |
| void | open (const char *name, unsigned size, int flags=0) |
| Opens or creates a shared memory segment. | |
| void | unmap () |
| Unmaps the shared memory segment. | |
A class for operation on a (one) shared memory segment.
Open flags for open().
| void base::SharedMemory::destroy | ( | ) |
Destroys the shared memory segment.
Under Linux you must explicitly destroy a shared memory segment with this method. Windows destroys a shared memory segment when there are no more open handles to it, so this method does nothing.
Reimplemented in base::SynchronizedSharedMemory.
| void* base::SharedMemory::getAddr | ( | ) | const |
Gets the start address of the shared memory segment in this process.
| void* base::SharedMemory::map | ( | bool | rw = true, |
|
| void * | addr = NULL | |||
| ) |
Maps the shared memory segment into the address space of this process.
| rw | true to map read-write, false to map read-only | |
| addr | hint address |
| void base::SharedMemory::open | ( | const char * | name, | |
| unsigned | size, | |||
| int | flags = 0 | |||
| ) |
Opens or creates a shared memory segment.
| name | the segment name, must be an integer in string form under Linux | |
| size | size of the segment in bytes | |
| flags | open flags |
Reimplemented in base::SynchronizedSharedMemory.
1.7.1