Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
simple_stats.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_UTIL_SIMPLE_STATS_H_
20 #define PAGESPEED_KERNEL_UTIL_SIMPLE_STATS_H_
21 
29 
30 namespace net_instaweb {
31 
32 class ThreadSystem;
33 
36  public:
37  SimpleStatsVariable(StringPiece name, Statistics* stats);
38  virtual ~SimpleStatsVariable();
39  virtual StringPiece GetName() const { return StringPiece(); }
40 
41  void set_mutex(AbstractMutex* mutex) { mutex_.reset(mutex); }
42 
43  protected:
44  virtual AbstractMutex* mutex() const { return mutex_.get(); }
45  virtual int64 GetLockHeld() const;
46  virtual int64 SetReturningPreviousValueLockHeld(int64 value);
47 
48  private:
49  int64 value_;
51 
52 };
53 
55 class SimpleStats : public ScalarStatisticsTemplate<SimpleStatsVariable> {
56  public:
59  explicit SimpleStats(ThreadSystem* thread_system);
60  virtual ~SimpleStats();
61 
62  void SetThreadSystem(ThreadSystem* x);
63  ThreadSystem* thread_system() const { return thread_system_; }
64 
65  virtual CountHistogram* NewHistogram(StringPiece name);
66  virtual Var* NewVariable(StringPiece name);
67  virtual UpDown* NewUpDownCounter(StringPiece name);
68 
69  private:
70  ThreadSystem* thread_system_;
71 
72 
73 };
74 
75 }
76 
77 #endif
TimeDVariable.
Definition: statistics_template.h:358
virtual Var * NewVariable(StringPiece name)
Interface to subclass.
virtual UpDown * NewUpDownCounter(StringPiece name)
Interface to subclass.
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
virtual int64 GetLockHeld() const
Get/Setters that may only be called if you already hold the mutex.
Definition: scoped_ptr.h:30
SimpleStats(ThreadSystem *thread_system)
Simple name/value pair statistics implementation.
Definition: simple_stats.h:55
Trivial implementation. But Count() returns a meaningful value.
Definition: statistics.h:255
Definition: statistics.h:112
Definition: thread_system.h:40
These variables are thread-safe.
Definition: simple_stats.h:35