|
Gin
|
Creates a block of shared memory. More...
#include <gin_sharedmemory.h>
Public Member Functions | |
| SharedMemory (const juce::String &name, int size) | |
| Creates or opens a shared memory block. | |
| ~SharedMemory () | |
| Destructor. | |
| void * | getData () |
| Returns a pointer to the shared memory data. | |
| int | getSize () |
| Returns the actual size of the shared memory block in bytes. | |
Static Public Member Functions | |
| static void | remove (const juce::String &name) |
| Removes a shared memory block by name. | |
Creates a block of shared memory.
The first one to create the block sets the size otherwise it is ignored. The block may be a different size than requested, especially if it was already created.
On Unix based OSes, if a process using the block crashes, the block will leak. Clean it up later with remove() and it will be deleted when the last process stops using it. (No new processes will be able to attach)
On Windows the memory block will always disappear when the final process closes the handle / crashes.
| SharedMemory::SharedMemory | ( | const juce::String & | name, |
| int | size | ||
| ) |
Creates or opens a shared memory block.
If a block with this name already exists, it will be opened and the size parameter is ignored. Otherwise, a new block is created with the specified size. The actual size may differ from the requested size, especially if the block already existed.
| name | The unique system-wide name for this shared memory block |
| size | The desired size in bytes (only used when creating a new block) |
| SharedMemory::~SharedMemory | ( | ) |
Destructor.
Detaches from the shared memory block.
On Windows, if this is the last process using the block, it will be deleted. On Unix systems, the block will persist until explicitly removed with remove().
|
static |
Removes a shared memory block by name.
On Unix systems, this marks the block for deletion. It will be deleted when the last process detaches. On Windows, this has no effect as blocks are automatically cleaned up.
| name | The name of the shared memory block to remove |
| void * SharedMemory::getData | ( | ) |
Returns a pointer to the shared memory data.
This pointer can be used to read from or write to the shared memory. All processes sharing this memory block will see the same data.
| int SharedMemory::getSize | ( | ) |
Returns the actual size of the shared memory block in bytes.
This may differ from the requested size, especially if the block already existed when this SharedMemory object was created.