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

#include "shared_mem_statistics.h"

Inheritance diagram for net_instaweb::SharedMemVariable:
net_instaweb::MutexedScalar

Public Member Functions

 SharedMemVariable (StringPiece name, Statistics *stats)
 
virtual StringPiece GetName () const
 
- Public Member Functions inherited from net_instaweb::MutexedScalar
int64 Get () const
 
void Set (int64 value)
 
int64 SetReturningPreviousValue (int64 value)
 
int64 AddHelper (int64 delta)
 

Protected Member Functions

virtual AbstractMutexmutex () const
 
virtual int64 GetLockHeld () const
 Get/Setters that may only be called if you already hold the mutex.
 
virtual int64 SetReturningPreviousValueLockHeld (int64 value)
 
- Protected Member Functions inherited from net_instaweb::MutexedScalar
void SetLockHeld (int64 value)
 
int64 AddLockHeld (int64 delta)
 

Friends

class SharedMemStatistics
 
class SharedMemTimedVariable
 

Detailed Description

An implementation of Statistics using our shared memory infrastructure. These statistics will be shared amongst all processes and threads spawned by our host. Note that we will be obtaining a per-variable mutex for every read and write to these variables. Since this may be expensive, we may need each thread to keep a local cache and infrequently write through to this Statistics object.

Todo:
TODO(abliss): actually do this.

Because we must allocate shared memory segments and mutexes before any child processes and threads are created, all AddVariable calls must be done in the host before it starts forking/threading. Once all variables are added, you must call InitVariables(true), and then InitVariables(false) in every kid.

If a variable fails to initialize (due to either its mutex or the shared memory segment not working), it will not increment in that process (and a warning message will be logged). If the variable fails to initialize in the process that happens to serve a statistics page, then the variable will show up with value -1.


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