This represents a region of memory shared between between multiple processes that may contain mutexes.
virtual bool net_instaweb::AbstractSharedMemSegment::InitializeSharedMutex |
( |
size_t |
offset, |
|
|
MessageHandler * |
handler |
|
) |
| |
|
pure virtual |
To use a mutex in shared memory, you first need to dedicate some [offset, offset + SharedMutexSize()) chunk of memory to it. Then, exactly one process must call InitializeSharedMutex(offset), and all users must call AttachToSharedMutex(offset) afterwards.
InitializeSharedMutex returns whether it succeeded or not. AttachToSharedMutex returns a fresh object, giving ownership to the caller. The object returned is outside shared memory, and acts a helper for referring to the shared state.