proxygen
Codel.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, 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 #pragma once
18 
19 #include <atomic>
20 #include <chrono>
21 
23 
24 DECLARE_int32(codel_interval);
25 DECLARE_int32(codel_target_delay);
26 
27 namespace folly {
28 
57 class Codel {
58  public:
59  Codel();
60 
67  bool overloaded(std::chrono::nanoseconds delay);
68 
75  int getLoad();
76 
77  std::chrono::nanoseconds getMinDelay();
78  std::chrono::milliseconds getInterval();
79  std::chrono::milliseconds getTargetDelay();
80  std::chrono::milliseconds getSloughTimeout();
81 
82  private:
83  std::atomic<uint64_t> codelMinDelayNs_;
84  std::atomic<uint64_t> codelIntervalTimeNs_;
85 
86  // flag to make overloaded() thread-safe, since we only want
87  // to reset the delay once per time period
88  std::atomic<bool> codelResetDelay_;
89 
90  std::atomic<bool> overloaded_;
91 };
92 
93 } // namespace folly
std::atomic< bool > overloaded_
Definition: Codel.h:90
std::chrono::milliseconds getTargetDelay()
Definition: Codel.cpp:97
int getLoad()
Definition: Codel.cpp:83
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
std::atomic< uint64_t > codelIntervalTimeNs_
Definition: Codel.h:84
std::atomic< bool > codelResetDelay_
Definition: Codel.h:88
std::chrono::nanoseconds getMinDelay()
Definition: Codel.cpp:89
bool overloaded(std::chrono::nanoseconds delay)
Definition: Codel.cpp:37
std::chrono::milliseconds getInterval()
Definition: Codel.cpp:93
std::atomic< uint64_t > codelMinDelayNs_
Definition: Codel.h:83
std::chrono::milliseconds getSloughTimeout()
Definition: Codel.cpp:101
DECLARE_int32(codel_interval)