Page Speed Optimization Libraries
1.3.25.1
|
#include "abstract_shared_mem.h"
Public Member Functions | |
virtual | ~AbstractSharedMemSegment () |
virtual volatile char * | Base ()=0 |
virtual size_t | SharedMutexSize () const =0 |
virtual bool | InitializeSharedMutex (size_t offset, MessageHandler *handler)=0 |
virtual AbstractMutex * | AttachToSharedMutex (size_t offset)=0 |
This represents a region of memory shared between between multiple processes that may contain mutexes.
virtual net_instaweb::AbstractSharedMemSegment::~AbstractSharedMemSegment | ( | ) | [virtual] |
Destroying the segment object detaches from it, making all pointers into it invalid.
virtual volatile char* net_instaweb::AbstractSharedMemSegment::Base | ( | ) | [pure virtual] |
Returns the base address of the segment. Note that there is no guarantee that this address will be the same for other processes attached to the same segment.
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.
virtual size_t net_instaweb::AbstractSharedMemSegment::SharedMutexSize | ( | ) | const [pure virtual] |
This returns the number of bytes a mutex inside shared memory takes.