Page Speed Optimization Libraries
1.2.24.1
|
#include "shared_mem_statistics.h"
Public Member Functions | |
int64 | Get () const |
virtual int64 | SetReturningPreviousValue (int64 new_value) |
Atomic. | |
virtual void | Set (int64 new_value) |
virtual int64 | Add (int delta) |
virtual StringPiece | GetName () const |
AbstractMutex * | mutex () |
Friends | |
class | SharedMemConsoleStatisticsLogger |
class | SharedMemStatistics |
class | SharedMemTimedVariable |
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.
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.
virtual int64 net_instaweb::SharedMemVariable::Add | ( | int | delta | ) | [virtual] |
Adds 'delta' to the variable's value, returning the result. This is virtual so that subclasses can add platform-specific atomicity.
Reimplemented from net_instaweb::Variable.
virtual StringPiece net_instaweb::SharedMemVariable::GetName | ( | ) | const [inline, virtual] |
Return some name representing the variable, provided that the specific implementation has some sensible way of doing so.
Implements net_instaweb::Variable.