proxygen
Window.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <cstdint>
13 
14 namespace proxygen {
15 
20 class Window {
21  public:
27  explicit Window(uint32_t capacity);
28 
34  int32_t getSize() const;
35 
42 
47  uint32_t getCapacity() const;
48 
54  uint32_t getOutstanding() const;
55 
64  bool reserve(uint32_t amount, bool strict = true);
65 
70  bool free(uint32_t amount);
71 
77  bool setCapacity(uint32_t capacity);
78 
79  private:
81  int32_t capacity_{0}; // always positive
82 };
83 
84 }
int32_t outstanding_
Definition: Window.h:80
uint32_t getCapacity() const
Definition: Window.cpp:32
uint32_t getOutstanding() const
Definition: Window.cpp:37
int32_t getSize() const
Definition: Window.cpp:23
bool reserve(uint32_t amount, bool strict=true)
Definition: Window.cpp:41
Window(uint32_t capacity)
Definition: Window.cpp:19
bool setCapacity(uint32_t capacity)
Definition: Window.cpp:84
int32_t capacity_
Definition: Window.h:81
bool free(uint32_t amount)
Definition: Window.cpp:63
uint32_t getNonNegativeSize() const
Definition: Window.cpp:27