Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
a13730a4
Commit
a13730a4
authored
May 07, 2019
by
helei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add explicit key word
parent
cc6642bd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
6 deletions
+62
-6
adaptive_connection_type.h
src/brpc/adaptive_connection_type.h
+0
-0
adaptive_max_concurrency.h
src/brpc/adaptive_max_concurrency.h
+3
-3
adaptive_protocol_type.h
src/brpc/adaptive_protocol_type.h
+2
-2
server.cpp
src/brpc/server.cpp
+1
-1
brpc_adaptive_class_unittest.cpp
test/brpc_adaptive_class_unittest.cpp
+56
-0
No files found.
src/brpc/adaptive_connection_type.h
View file @
a13730a4
src/brpc/adaptive_max_concurrency.h
View file @
a13730a4
...
@@ -27,9 +27,9 @@ namespace brpc {
...
@@ -27,9 +27,9 @@ namespace brpc {
class
AdaptiveMaxConcurrency
{
class
AdaptiveMaxConcurrency
{
public
:
public
:
AdaptiveMaxConcurrency
();
explicit
AdaptiveMaxConcurrency
();
AdaptiveMaxConcurrency
(
int
max_concurrency
);
explicit
AdaptiveMaxConcurrency
(
int
max_concurrency
);
AdaptiveMaxConcurrency
(
const
butil
::
StringPiece
&
value
);
explicit
AdaptiveMaxConcurrency
(
const
butil
::
StringPiece
&
value
);
// Non-trivial destructor to prevent AdaptiveMaxConcurrency from being
// Non-trivial destructor to prevent AdaptiveMaxConcurrency from being
// passed to variadic arguments without explicit type conversion.
// passed to variadic arguments without explicit type conversion.
...
...
src/brpc/adaptive_protocol_type.h
View file @
a13730a4
...
@@ -39,8 +39,8 @@ const char* ProtocolTypeToString(ProtocolType);
...
@@ -39,8 +39,8 @@ const char* ProtocolTypeToString(ProtocolType);
// Assignable by both ProtocolType and names.
// Assignable by both ProtocolType and names.
class
AdaptiveProtocolType
{
class
AdaptiveProtocolType
{
public
:
public
:
AdaptiveProtocolType
()
:
_type
(
PROTOCOL_UNKNOWN
)
{}
explicit
AdaptiveProtocolType
()
:
_type
(
PROTOCOL_UNKNOWN
)
{}
AdaptiveProtocolType
(
ProtocolType
type
)
:
_type
(
type
)
{}
explicit
AdaptiveProtocolType
(
ProtocolType
type
)
:
_type
(
type
)
{}
~
AdaptiveProtocolType
()
{}
~
AdaptiveProtocolType
()
{}
void
operator
=
(
ProtocolType
type
)
{
void
operator
=
(
ProtocolType
type
)
{
...
...
src/brpc/server.cpp
View file @
a13730a4
...
@@ -690,7 +690,7 @@ static bool CreateConcurrencyLimiter(const AdaptiveMaxConcurrency& amc,
...
@@ -690,7 +690,7 @@ static bool CreateConcurrencyLimiter(const AdaptiveMaxConcurrency& amc,
return
true
;
return
true
;
}
}
static
AdaptiveMaxConcurrency
g_default_max_concurrency_of_method
=
0
;
static
AdaptiveMaxConcurrency
g_default_max_concurrency_of_method
(
0
)
;
int
Server
::
StartInternal
(
const
butil
::
ip_t
&
ip
,
int
Server
::
StartInternal
(
const
butil
::
ip_t
&
ip
,
const
PortRange
&
port_range
,
const
PortRange
&
port_range
,
...
...
test/brpc_adaptive_class_unittest.cpp
0 → 100755
View file @
a13730a4
// brpc - A framework to host and access services throughout Baidu.
// Copyright (c) 2014 Baidu, Inc.
// Date: 2019/04/16 23:41:04
#include <gtest/gtest.h>
#include "brpc/adaptive_max_concurrency.h"
#include "brpc/adaptive_protocol_type.h"
#include "brpc/adaptive_connection_type.h"
const
std
::
string
kAutoCL
=
"aUto"
;
const
std
::
string
kHttp
=
"hTTp"
;
const
std
::
string
kPooled
=
"PoOled"
;
TEST
(
AdaptiveMaxConcurrencyTest
,
ShouldConvertCorrectly
)
{
brpc
::
AdaptiveMaxConcurrency
amc
(
0
);
EXPECT_EQ
(
brpc
::
AdaptiveMaxConcurrency
::
UNLIMITED
(),
amc
.
type
());
EXPECT_EQ
(
brpc
::
AdaptiveMaxConcurrency
::
UNLIMITED
(),
amc
.
value
());
EXPECT_EQ
(
0
,
int
(
amc
));
EXPECT_TRUE
(
amc
==
brpc
::
AdaptiveMaxConcurrency
::
UNLIMITED
());
amc
=
10
;
EXPECT_EQ
(
brpc
::
AdaptiveMaxConcurrency
::
CONSTANT
(),
amc
.
type
());
EXPECT_EQ
(
"10"
,
amc
.
value
());
EXPECT_EQ
(
10
,
int
(
amc
));
EXPECT_EQ
(
amc
,
"10"
);
amc
=
kAutoCL
;
EXPECT_EQ
(
kAutoCL
,
amc
.
type
());
EXPECT_EQ
(
kAutoCL
,
amc
.
value
());
EXPECT_EQ
(
int
(
amc
),
-
1
);
EXPECT_TRUE
(
amc
==
"auto"
);
}
TEST
(
AdaptiveProtocolType
,
ShouldConvertCorrectly
)
{
brpc
::
AdaptiveProtocolType
apt
;
apt
=
kHttp
;
EXPECT_EQ
(
apt
,
brpc
::
ProtocolType
::
PROTOCOL_HTTP
);
apt
=
brpc
::
ProtocolType
::
PROTOCOL_HTTP
;
EXPECT_EQ
(
apt
,
brpc
::
ProtocolType
::
PROTOCOL_HTTP
);
}
TEST
(
AdaptiveConnectionTypeTest
,
ShouldConvertCorrectly
)
{
brpc
::
AdaptiveConnectionType
act
;
act
=
brpc
::
ConnectionType
::
CONNECTION_TYPE_POOLED
;
EXPECT_EQ
(
act
,
brpc
::
ConnectionType
::
CONNECTION_TYPE_POOLED
);
act
=
kPooled
;
EXPECT_EQ
(
act
,
brpc
::
ConnectionType
::
CONNECTION_TYPE_POOLED
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment