#include <SharedMemory.h>
Inherits AZ::SharedMemory_Unimplemented.
Inherited by AZ::SharedMemoryRingBuffer.
|
typedef AZStd::lock_guard< SharedMemory > | MemoryGuard |
|
enum | AccessMode { ReadOnly
, ReadWrite
} |
|
enum | CreateResult { CreateFailed
, CreatedNew
, CreatedExisting
} |
|
|
CreateResult | Create (const char *name, unsigned int size, bool openIfCreated=false) |
| Create a shared memory block. If openIfCreated is false all memory will be cleared to 0.
|
|
bool | Open (const char *name) |
| Open an existing shared memory block. If the block doesn't exist we will return false otherwise true.
|
|
bool | IsReady () const |
|
void | Close () |
|
bool | Map (AccessMode mode=ReadWrite, unsigned int size=0) |
| Maps to the created map. If size == 0 it will map the whole memory.
|
|
bool | IsMapped () const |
|
bool | UnMap () |
|
void | lock () |
| Naming is conforming with AZStd::lock_guard/unique_lock/etc.
|
|
bool | try_lock () |
|
void | unlock () |
|
bool | IsLockAbandoned () |
|
const char * | GetName () const |
|
void * | Data () |
|
const void * | Data () const |
|
unsigned int | DataSize () const |
|
void | Clear () |
| Sets all data (if mapped to 0)
|
|
|
| SharedMemory (const SharedMemory &) |
|
SharedMemory & | operator= (const SharedMemory &) |
|
bool | IsReady () const |
|
bool | IsMapHandleValid () const |
|
CreateResult | Create (const char *name, unsigned int size, bool openIfCreated) |
|
bool | Open (const char *name) |
|
void | Close () |
|
bool | Map (AccessMode mode, unsigned int size) |
|
bool | UnMap () |
|
void | lock () |
|
bool | try_lock () |
|
void | unlock () |
|
bool | IsLockAbandoned () |
|
bool | IsWaitFailed () const |
|
|
void * | m_data |
|
void * | m_globalMutex = nullptr |
|
char | m_name [128] |
|
void * | m_mappedBase |
|
unsigned int | m_dataSize |
|
|
static int | GetLastError () |
|
Shared memory is a helper class to provide shared memory for IPC (Inter Process Communication). Technically this is the fastest way to communicate between two process on the same machine. Obviously for remote data exchange you will need to use Sockets/DCOM/etc.
◆ IsLockAbandoned()
bool AZ::SharedMemory::IsLockAbandoned |
( |
| ) |
|
This function will return correct result only when you own the lock (you are inside lock()/unlock(). Otherwise it will always return false. IMPORTANT: It's recommended that you check after each call to lock if the mutex was abandoned and if so to reset shared memory as the state is unknown. As usual there are exceptional cases it which this can be fine, this is why we don't do it automatically.
The documentation for this class was generated from the following file:
- Code/Framework/AzCore/AzCore/IPC/SharedMemory.h