Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
queued_expensive_operation_controller.h
Go to the documentation of this file.
1 // Copyright 2015 Google Inc.
16 
17 #ifndef PAGESPEED_CONTROLLER_QUEUED_EXPENSIVE_OPERATION_CONTROLLER_H_
18 #define PAGESPEED_CONTROLLER_QUEUED_EXPENSIVE_OPERATION_CONTROLLER_H_
19 
20 #include <queue>
21 
28 #include "pagespeed/kernel/base/thread_annotations.h"
30 
31 namespace net_instaweb {
32 
42  public:
43  static const char kActiveExpensiveOperations[];
44  static const char kQueuedExpensiveOperations[];
45  static const char kPermittedExpensiveOperations[];
46 
47  QueuedExpensiveOperationController(int max_expensive_operations,
48  ThreadSystem* thread_system,
49  Statistics* stats);
51 
53  virtual void ScheduleExpensiveOperation(Function* callback);
54  virtual void NotifyExpensiveOperationComplete();
55 
56  static void InitStats(Statistics* stats);
57 
58  private:
59  void IncrementInProgress() EXCLUSIVE_LOCKS_REQUIRED(mutex_);
60  void DecrementInProgress() EXCLUSIVE_LOCKS_REQUIRED(mutex_);
61 
62  void Enqueue(Function* function) EXCLUSIVE_LOCKS_REQUIRED(mutex_);
63  Function* Dequeue() EXCLUSIVE_LOCKS_REQUIRED(mutex_);
64 
65  const int max_in_progress_;
66  std::queue<Function*> queue_ GUARDED_BY(mutex_);
67  int num_in_progress_ GUARDED_BY(mutex_);
69  UpDownCounter* active_operations_counter_;
70  UpDownCounter* queued_operations_counter_;
71  TimedVariable* permitted_operations_counter_;
72 
73 
74 };
75 
76 }
77 
78 #endif
Definition: queued_expensive_operation_controller.h:40
Definition: expensive_operation_controller.h:28
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
virtual void ScheduleExpensiveOperation(Function *callback)
ExpensiveOperationController interface.
Definition: scoped_ptr.h:30
Definition: function.h:47
Definition: thread_system.h:40
Definition: statistics.h:73
Definition: statistics.h:298