Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::SharedCircularBuffer Class Reference

#include "shared_circular_buffer.h"

Inheritance diagram for net_instaweb::SharedCircularBuffer:
net_instaweb::Writer

Public Member Functions

 SharedCircularBuffer (AbstractSharedMem *shm_runtime, const int buffer_capacity, const GoogleString &filename_prefix, const GoogleString &filename_suffix)
 
bool InitSegment (bool parent, MessageHandler *handler)
 
void Clear ()
 Reset circular buffer.
 
virtual bool Write (const StringPiece &message, MessageHandler *handler)
 Write content to circular buffer.
 
virtual bool Flush (MessageHandler *message_handler)
 
virtual bool Dump (Writer *writer, MessageHandler *handler)
 Write content of data in buffer to writer, without clearing the buffer.
 
GoogleString ToString (MessageHandler *handler)
 Return data content as string. This is for test purposes.
 
void GlobalCleanup (MessageHandler *handler)
 

Detailed Description

Shared memory circular buffer, the content of its shared memory segment is a Mutex and a CircularBuffer. In parent process, we initialize a shared memory segment. Then we create a SharedCircularBuffer object in each process and attach it to the segment by calling InitSegment(true, handler) once in the parent process and calling InitSegment(false, handler) in each child.

Constructor & Destructor Documentation

net_instaweb::SharedCircularBuffer::SharedCircularBuffer ( AbstractSharedMem shm_runtime,
const int  buffer_capacity,
const GoogleString filename_prefix,
const GoogleString filename_suffix 
)

Construct with shared memory, data buffer capacity, filename_prefix and filename_suffix. filename_prefix and filename_suffix are used to name segment for the shared circular buffer.

Member Function Documentation

void net_instaweb::SharedCircularBuffer::GlobalCleanup ( MessageHandler handler)

This should be called from the root process as it is about to exit, when no future children are expected to start.

bool net_instaweb::SharedCircularBuffer::InitSegment ( bool  parent,
MessageHandler handler 
)

Initialize the shared memory segment. parent = true if this is invoked in root process – initialize the shared memory; parent = false if this is invoked in child process – attach to existing segment.


The documentation for this class was generated from the following file: