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
b6a6c58e
Commit
b6a6c58e
authored
Jul 25, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify the MethodStatus::SetConcurrencyLimiter from the public to be private.
parent
7654d8e0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
26 deletions
+31
-26
method_status.cpp
src/brpc/details/method_status.cpp
+23
-0
method_status.h
src/brpc/details/method_status.h
+8
-26
No files found.
src/brpc/details/method_status.cpp
View file @
b6a6c58e
...
@@ -127,6 +127,29 @@ void MethodStatus::Describe(
...
@@ -127,6 +127,29 @@ void MethodStatus::Describe(
_nprocessing
,
options
,
false
);
_nprocessing
,
options
,
false
);
}
}
int
&
MethodStatus
::
max_concurrency_ref
()
{
if
(
NULL
==
_cl
)
{
const
ConcurrencyLimiter
*
cl
=
ConcurrencyLimiterExtension
()
->
Find
(
"constant"
);
if
(
NULL
==
cl
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrentLimiter by `constant`"
;
}
ConcurrencyLimiter
*
cl_copy
=
cl
->
New
();
if
(
NULL
==
cl_copy
)
{
LOG
(
FATAL
)
<<
"Fail to new ConcurrencyLimiter"
;
}
_cl
=
cl_copy
;
}
return
_cl
->
MaxConcurrencyRef
();
}
void
MethodStatus
::
SetConcurrencyLimiter
(
ConcurrencyLimiter
*
cl
)
{
if
(
NULL
!=
_cl
)
{
_cl
->
Destroy
();
}
_cl
=
cl
;
}
ScopedMethodStatus
::~
ScopedMethodStatus
()
{
ScopedMethodStatus
::~
ScopedMethodStatus
()
{
if
(
_status
)
{
if
(
_status
)
{
_status
->
OnResponded
(
_c
->
ErrorCode
(),
butil
::
cpuwide_time_us
()
-
_start_parse_us
);
_status
->
OnResponded
(
_c
->
ErrorCode
(),
butil
::
cpuwide_time_us
()
-
_start_parse_us
);
...
...
src/brpc/details/method_status.h
View file @
b6a6c58e
...
@@ -53,6 +53,8 @@ public:
...
@@ -53,6 +53,8 @@ public:
// Describe internal vars, used by /status
// Describe internal vars, used by /status
void
Describe
(
std
::
ostream
&
os
,
const
DescribeOptions
&
)
const
;
void
Describe
(
std
::
ostream
&
os
,
const
DescribeOptions
&
)
const
;
// Current maximum concurrency of method.
// Return 0 if the maximum concurrency is not restricted.
int
max_concurrency
()
const
{
int
max_concurrency
()
const
{
if
(
NULL
==
_cl
)
{
if
(
NULL
==
_cl
)
{
return
0
;
return
0
;
...
@@ -61,36 +63,16 @@ public:
...
@@ -61,36 +63,16 @@ public:
}
}
}
}
// Note: This method is not thread safe and can only be called before
// the server is started.
int
&
max_concurrency_ref
()
{
if
(
NULL
==
_cl
)
{
const
ConcurrencyLimiter
*
cl
=
ConcurrencyLimiterExtension
()
->
Find
(
"constant"
);
if
(
NULL
==
cl
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrentLimiter by `constant`"
;
}
ConcurrencyLimiter
*
cl_copy
=
cl
->
New
();
if
(
NULL
==
cl_copy
)
{
LOG
(
FATAL
)
<<
"Fail to new ConcurrencyLimiter"
;
}
_cl
=
cl_copy
;
}
return
_cl
->
MaxConcurrencyRef
();
}
void
SetConcurrencyLimiter
(
ConcurrencyLimiter
*
cl
)
{
if
(
NULL
!=
_cl
)
{
_cl
->
Destroy
();
}
_cl
=
cl
;
}
private
:
private
:
friend
class
ScopedMethodStatus
;
friend
class
ScopedMethodStatus
;
friend
class
Server
;
DISALLOW_COPY_AND_ASSIGN
(
MethodStatus
);
DISALLOW_COPY_AND_ASSIGN
(
MethodStatus
);
// Note: Following methods are not thread safe and can only be called
// before the server is started.
int
&
max_concurrency_ref
();
void
SetConcurrencyLimiter
(
ConcurrencyLimiter
*
cl
);
ConcurrencyLimiter
*
_cl
;
ConcurrencyLimiter
*
_cl
;
bvar
::
Adder
<
int64_t
>
_nerror
;
bvar
::
Adder
<
int64_t
>
_nerror
;
bvar
::
LatencyRecorder
_latency_rec
;
bvar
::
LatencyRecorder
_latency_rec
;
...
...
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