Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
worker.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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 
21 
22 #ifndef PAGESPEED_KERNEL_THREAD_WORKER_H_
23 #define PAGESPEED_KERNEL_THREAD_WORKER_H_
24 
28 
29 namespace net_instaweb {
30 
31 class Function;
32 class ThreadSystem;
33 class Waveform;
34 
42 class Worker {
43  public:
45  void Start();
46 
49  bool IsBusy();
50 
54  void ShutDown();
55 
59  void set_queue_size_stat(Waveform* x) { queue_size_ = x; }
60 
61  protected:
62  Worker(StringPiece thread_name, ThreadSystem* runtime);
63  virtual ~Worker();
64 
70  bool QueueIfPermitted(Function* closure);
71 
74  virtual bool IsPermitted(Function* closure) = 0;
75 
81  int NumJobs();
82 
83  private:
84  class WorkThread;
85  friend class WorkThread;
86 
88  void UpdateQueueSizeStat(int size);
89 
90  scoped_ptr<WorkThread> thread_;
91  Waveform* queue_size_;
92 
93 
94 };
95 
96 }
97 
98 #endif
void set_queue_size_stat(Waveform *x)
Definition: worker.h:59
Definition: waveform.h:45
Definition: function.h:47
void Start()
Tries to start the work thread (if it hasn't been started already).
Definition: thread_system.h:40
virtual bool IsPermitted(Function *closure)=0
bool QueueIfPermitted(Function *closure)
Definition: worker.h:42