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 | List of all members
net_instaweb::UpDownCounter Class Referenceabstract

#include "statistics.h"

Inheritance diagram for net_instaweb::UpDownCounter:
net_instaweb::SplitUpDownCounter net_instaweb::UpDownTemplate< Impl > net_instaweb::UpDownTemplate< NullStatisticsVariable > net_instaweb::UpDownTemplate< SharedMemVariable > net_instaweb::UpDownTemplate< SimpleStatsVariable >

Public Member Functions

virtual int64 Get () const =0
 
virtual StringPiece GetName () const =0
 
virtual int64 SetReturningPreviousValue (int64 value)
 
virtual void Set (int64 value)=0
 
void Clear ()
 
int64 Add (int64 delta)
 

Protected Member Functions

virtual int64 AddHelper (int64 delta)=0
 This is virtual so that subclasses can add platform-specific atomicity.
 

Detailed Description

UpDownCounters are variables that can also be decreased (e.g. Add of a negative number) or Set to an arbitrary value.

Todo:
TODO(jmarantz): Make this not inherit from Variable, which will simplify the 'CheckNotNegative' and its ifndefs, but will require us to do more accurate type bookkeeping in tests, etc.
Todo:
TODO(jmarantz): consider renaming Variable->Counter, UpDownCounter->Variable.

Member Function Documentation

virtual StringPiece net_instaweb::UpDownCounter::GetName ( ) const
pure virtual

Return some name representing the variable, provided that the specific implementation has some sensible way of doing so.

Implemented in net_instaweb::UpDownTemplate< Impl >, net_instaweb::UpDownTemplate< SharedMemVariable >, net_instaweb::UpDownTemplate< NullStatisticsVariable >, net_instaweb::UpDownTemplate< SimpleStatsVariable >, and net_instaweb::SplitUpDownCounter.

virtual int64 net_instaweb::UpDownCounter::SetReturningPreviousValue ( int64  value)
virtual

Sets the specified value, returning the previous value. This can be used to by two competing threads/processes to determine which thread modified the value first. The default implementation is non-atomic, but implementations can override to provide an atomic version.

Non-atomic implementations may result in multiple concurrent updates each returning the old value. In an atomic implementation, only one concurrent update will return the old value.

Reimplemented in net_instaweb::SplitUpDownCounter.


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