|
1 | 1 | /*
|
2 | 2 | *
|
3 |
| - * Copyright 2019 gRPC authors. |
| 3 | + * Copyright 2016 gRPC authors. |
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | 6 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | #ifndef GRPCPP_RESOURCE_QUOTA_H
|
20 | 20 | #define GRPCPP_RESOURCE_QUOTA_H
|
21 | 21 |
|
22 |
| -#include <grpcpp/resource_quota_impl.h> |
| 22 | +struct grpc_resource_quota; |
| 23 | + |
| 24 | +#include <grpcpp/impl/codegen/config.h> |
| 25 | +#include <grpcpp/impl/codegen/grpc_library.h> |
23 | 26 |
|
24 | 27 | namespace grpc {
|
25 | 28 |
|
26 |
| -typedef ::grpc_impl::ResourceQuota ResourceQuota; |
| 29 | +/// ResourceQuota represents a bound on memory and thread usage by the gRPC |
| 30 | +/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder), |
| 31 | +/// or a client channel (via \a ChannelArguments). |
| 32 | +/// gRPC will attempt to keep memory and threads used by all attached entities |
| 33 | +/// below the ResourceQuota bound. |
| 34 | +class ResourceQuota final : private ::grpc::GrpcLibraryCodegen { |
| 35 | + public: |
| 36 | + /// \param name - a unique name for this ResourceQuota. |
| 37 | + explicit ResourceQuota(const grpc::string& name); |
| 38 | + ResourceQuota(); |
| 39 | + ~ResourceQuota(); |
| 40 | + |
| 41 | + /// Resize this \a ResourceQuota to a new size. If \a new_size is smaller |
| 42 | + /// than the current size of the pool, memory usage will be monotonically |
| 43 | + /// decreased until it falls under \a new_size. |
| 44 | + /// No time bound is given for this to occur however. |
| 45 | + ResourceQuota& Resize(size_t new_size); |
| 46 | + |
| 47 | + /// Set the max number of threads that can be allocated from this |
| 48 | + /// ResourceQuota object. |
| 49 | + /// |
| 50 | + /// If the new_max_threads value is smaller than the current value, no new |
| 51 | + /// threads are allocated until the number of active threads fall below |
| 52 | + /// new_max_threads. There is no time bound on when this may happen i.e none |
| 53 | + /// of the current threads are forcefully destroyed and all threads run their |
| 54 | + /// normal course. |
| 55 | + ResourceQuota& SetMaxThreads(int new_max_threads); |
| 56 | + |
| 57 | + grpc_resource_quota* c_resource_quota() const { return impl_; } |
| 58 | + |
| 59 | + private: |
| 60 | + ResourceQuota(const ResourceQuota& rhs); |
| 61 | + ResourceQuota& operator=(const ResourceQuota& rhs); |
| 62 | + |
| 63 | + grpc_resource_quota* const impl_; |
| 64 | +}; |
| 65 | + |
27 | 66 | } // namespace grpc
|
28 | 67 |
|
29 | 68 | #endif // GRPCPP_RESOURCE_QUOTA_H
|
0 commit comments