Skip to content

Commit d8d8bec

Browse files
committed
Moving ::grpc::ResourceQuota to ::grpc_impl::ResouceQuota
This change moves ResourceQuota class fron grpc namespace to grpc_impl namespace. Signed-off-by: Karthik Ravi Shankar <[email protected]>
1 parent 08ad670 commit d8d8bec

File tree

16 files changed

+117
-51
lines changed

16 files changed

+117
-51
lines changed

BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ GRPCXX_PUBLIC_HDRS = [
192192
"include/grpc++/impl/service_type.h",
193193
"include/grpc++/impl/sync_cxx11.h",
194194
"include/grpc++/impl/sync_no_cxx11.h",
195-
"include/grpc++/resource_quota.h",
196195
"include/grpc++/security/auth_context.h",
196+
"include/grpc++/resource_quota.h",
197197
"include/grpc++/security/auth_metadata_processor.h",
198198
"include/grpc++/security/credentials.h",
199199
"include/grpc++/security/server_credentials.h",
@@ -241,6 +241,7 @@ GRPCXX_PUBLIC_HDRS = [
241241
"include/grpcpp/impl/sync_cxx11.h",
242242
"include/grpcpp/impl/sync_no_cxx11.h",
243243
"include/grpcpp/resource_quota.h",
244+
"include/grpcpp/resource_quota_impl.h",
244245
"include/grpcpp/security/auth_context.h",
245246
"include/grpcpp/security/auth_metadata_processor.h",
246247
"include/grpcpp/security/credentials.h",

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,7 @@ foreach(_hdr
30143014
include/grpcpp/impl/server_initializer.h
30153015
include/grpcpp/impl/service_type.h
30163016
include/grpcpp/resource_quota.h
3017+
include/grpcpp/resource_quota_impl.h
30173018
include/grpcpp/security/auth_context.h
30183019
include/grpcpp/security/auth_metadata_processor.h
30193020
include/grpcpp/security/credentials.h
@@ -3604,6 +3605,7 @@ foreach(_hdr
36043605
include/grpcpp/impl/server_initializer.h
36053606
include/grpcpp/impl/service_type.h
36063607
include/grpcpp/resource_quota.h
3608+
include/grpcpp/resource_quota_impl.h
36073609
include/grpcpp/security/auth_context.h
36083610
include/grpcpp/security/auth_metadata_processor.h
36093611
include/grpcpp/security/credentials.h
@@ -4563,6 +4565,7 @@ foreach(_hdr
45634565
include/grpcpp/impl/server_initializer.h
45644566
include/grpcpp/impl/service_type.h
45654567
include/grpcpp/resource_quota.h
4568+
include/grpcpp/resource_quota_impl.h
45664569
include/grpcpp/security/auth_context.h
45674570
include/grpcpp/security/auth_metadata_processor.h
45684571
include/grpcpp/security/credentials.h

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,6 +5438,7 @@ PUBLIC_HEADERS_CXX += \
54385438
include/grpcpp/impl/server_initializer.h \
54395439
include/grpcpp/impl/service_type.h \
54405440
include/grpcpp/resource_quota.h \
5441+
include/grpcpp/resource_quota_impl.h \
54415442
include/grpcpp/security/auth_context.h \
54425443
include/grpcpp/security/auth_metadata_processor.h \
54435444
include/grpcpp/security/credentials.h \
@@ -6037,6 +6038,7 @@ PUBLIC_HEADERS_CXX += \
60376038
include/grpcpp/impl/server_initializer.h \
60386039
include/grpcpp/impl/service_type.h \
60396040
include/grpcpp/resource_quota.h \
6041+
include/grpcpp/resource_quota_impl.h \
60406042
include/grpcpp/security/auth_context.h \
60416043
include/grpcpp/security/auth_metadata_processor.h \
60426044
include/grpcpp/security/credentials.h \
@@ -6949,6 +6951,7 @@ PUBLIC_HEADERS_CXX += \
69496951
include/grpcpp/impl/server_initializer.h \
69506952
include/grpcpp/impl/service_type.h \
69516953
include/grpcpp/resource_quota.h \
6954+
include/grpcpp/resource_quota_impl.h \
69526955
include/grpcpp/security/auth_context.h \
69536956
include/grpcpp/security/auth_metadata_processor.h \
69546957
include/grpcpp/security/credentials.h \

build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@ filegroups:
13601360
- include/grpcpp/impl/server_initializer.h
13611361
- include/grpcpp/impl/service_type.h
13621362
- include/grpcpp/resource_quota.h
1363+
- include/grpcpp/resource_quota_impl.h
13631364
- include/grpcpp/security/auth_context.h
13641365
- include/grpcpp/security/auth_metadata_processor.h
13651366
- include/grpcpp/security/credentials.h

gRPC-C++.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Pod::Spec.new do |s|
105105
'include/grpcpp/impl/server_initializer.h',
106106
'include/grpcpp/impl/service_type.h',
107107
'include/grpcpp/resource_quota.h',
108+
'include/grpcpp/resource_quota_impl.h',
108109
'include/grpcpp/security/auth_context.h',
109110
'include/grpcpp/security/auth_metadata_processor.h',
110111
'include/grpcpp/security/credentials.h',

include/grpcpp/resource_quota.h

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright 2016 gRPC authors.
3+
* Copyright 2019 gRPC authors.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -19,50 +19,11 @@
1919
#ifndef GRPCPP_RESOURCE_QUOTA_H
2020
#define GRPCPP_RESOURCE_QUOTA_H
2121

22-
struct grpc_resource_quota;
23-
24-
#include <grpcpp/impl/codegen/config.h>
25-
#include <grpcpp/impl/codegen/grpc_library.h>
22+
#include <grpcpp/resource_quota_impl.h>
2623

2724
namespace grpc {
2825

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 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-
26+
typedef ::grpc_impl::ResourceQuota ResourceQuota;
6627
} // namespace grpc
6728

6829
#endif // GRPCPP_RESOURCE_QUOTA_H
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
*
3+
* Copyright 2016 gRPC authors.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
#ifndef GRPCPP_RESOURCE_QUOTA_IMPL_H
20+
#define GRPCPP_RESOURCE_QUOTA_IMPL_H
21+
22+
struct grpc_resource_quota;
23+
24+
#include <grpcpp/impl/codegen/config.h>
25+
#include <grpcpp/impl/codegen/grpc_library.h>
26+
27+
namespace grpc_impl {
28+
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+
66+
} // namespace grpc_impl
67+
68+
#endif // GRPCPP_RESOURCE_QUOTA_IMPL_H

include/grpcpp/server_builder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@
3535

3636
struct grpc_resource_quota;
3737

38+
namespace grpc_impl {
39+
40+
class ResourceQuota;
41+
}
42+
3843
namespace grpc {
3944

4045
class AsyncGenericService;
41-
class ResourceQuota;
4246
class CompletionQueue;
4347
class Server;
4448
class ServerCompletionQueue;
@@ -186,7 +190,7 @@ class ServerBuilder {
186190
grpc_compression_algorithm algorithm);
187191

188192
/// Set the attached buffer pool for this server
189-
ServerBuilder& SetResourceQuota(const ResourceQuota& resource_quota);
193+
ServerBuilder& SetResourceQuota(const ::grpc_impl::ResourceQuota& resource_quota);
190194

191195
ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option);
192196

include/grpcpp/support/channel_arguments.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
#include <grpc/grpc.h>
2727
#include <grpcpp/support/config.h>
2828

29+
namespace grpc_impl {
30+
31+
class ResourceQuota;
32+
}
33+
2934
namespace grpc {
3035
namespace testing {
3136
class ChannelArgumentsTest;
3237
} // namespace testing
3338

34-
class ResourceQuota;
3539

3640
/// Options for channel creation. The user can use generic setters to pass
3741
/// key value pairs down to C channel creation code. For gRPC related options,
@@ -83,7 +87,7 @@ class ChannelArguments {
8387
void SetUserAgentPrefix(const grpc::string& user_agent_prefix);
8488

8589
/// Set the buffer pool to be attached to the constructed channel.
86-
void SetResourceQuota(const ResourceQuota& resource_quota);
90+
void SetResourceQuota(const ::grpc_impl::ResourceQuota& resource_quota);
8791

8892
/// Set the max receive and send message sizes.
8993
void SetMaxReceiveMessageSize(int size);

src/cpp/common/channel_arguments.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void ChannelArguments::SetUserAgentPrefix(
143143
}
144144

145145
void ChannelArguments::SetResourceQuota(
146-
const grpc::ResourceQuota& resource_quota) {
146+
const grpc_impl::ResourceQuota& resource_quota) {
147147
SetPointerWithVtable(GRPC_ARG_RESOURCE_QUOTA,
148148
resource_quota.c_resource_quota(),
149149
grpc_resource_quota_arg_vtable());

0 commit comments

Comments
 (0)