~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/apache/mod_spdy_fetch_controller.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2012 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
 
 
17
 
// Author: morlovich@google.com (Maksim Orlovich)
18
 
//
19
 
// ModSpdyFetchController coordinates a threadpool and a rate controller between
20
 
// multiple ModSpdyFetcher objects. The basic usage pattern is that
21
 
// ModSpdyFetcher::Fetch calls ModSpdyFetchController::ScheduleBlockingFetch,
22
 
// which will then cause ModSpdyFetcher::BlockingFetch to be called on a
23
 
// thread in a hopefully intelligent manner.
24
 
 
25
 
#ifndef NET_INSTAWEB_APACHE_MOD_SPDY_FETCH_CONTROLLER_H_
26
 
#define NET_INSTAWEB_APACHE_MOD_SPDY_FETCH_CONTROLLER_H_
27
 
 
28
 
#include "net/instaweb/http/public/rate_controller.h"
29
 
#include "net/instaweb/util/public/atomic_bool.h"
30
 
#include "net/instaweb/util/public/basictypes.h"
31
 
#include "net/instaweb/util/public/queued_worker_pool.h"
32
 
#include "net/instaweb/util/public/string.h"
33
 
 
34
 
namespace net_instaweb {
35
 
 
36
 
class AsyncFetch;
37
 
class MessageHandler;
38
 
class ModSpdyFetcher;
39
 
class Statistics;
40
 
class Timer;
41
 
class ThreadSystem;
42
 
 
43
 
class ModSpdyFetchController {
44
 
 public:
45
 
  // Note: RateController::InitStats must have been called before using this.
46
 
  ModSpdyFetchController(int num_threads,
47
 
                         ThreadSystem* thread_system,
48
 
                         Timer* timer,
49
 
                         Statistics* statistics);
50
 
  ~ModSpdyFetchController();
51
 
 
52
 
  // This must be called for every statistics object in use before using this.
53
 
  static void InitStats(Statistics* statistics);
54
 
 
55
 
  // Arranges for fetcher->BlockingFetch to be called on our thread pool.
56
 
  void ScheduleBlockingFetch(
57
 
      ModSpdyFetcher* fetcher, const GoogleString& url, Statistics* stats,
58
 
      MessageHandler* message_handler, AsyncFetch* fetch);
59
 
 
60
 
  // Makes any further fetches quick-fail, and makes us more careful about
61
 
  // using external dependencies on things like stats.
62
 
  void ShutDown() { shutdown_.set_value(true); }
63
 
  bool is_shut_down() const { return shutdown_.value(); }
64
 
 
65
 
  Timer* timer() const { return timer_; }
66
 
 
67
 
 private:
68
 
  class FetchDispatcher;
69
 
 
70
 
  Timer* timer_;
71
 
  RateController rate_controller_;
72
 
  QueuedWorkerPool thread_pool_;
73
 
  AtomicBool shutdown_;
74
 
  DISALLOW_COPY_AND_ASSIGN(ModSpdyFetchController);
75
 
};
76
 
 
77
 
}  // namespace net_instaweb
78
 
 
79
 
#endif  // NET_INSTAWEB_APACHE_MOD_SPDY_FETCH_CONTROLLER_H_