Commit 93ba5e32 authored by TousakaRin's avatar TousakaRin

CreateConcurrencyLimiterOrDie would not return NULL now

parent 24afccac
......@@ -20,10 +20,6 @@ namespace brpc {
ConcurrencyLimiter* ConcurrencyLimiter::CreateConcurrencyLimiterOrDie(
const AdaptiveMaxConcurrency& max_concurrency) {
if (max_concurrency == "constant" && static_cast<int>(max_concurrency) == 0) {
return NULL;
}
const ConcurrencyLimiter* cl =
ConcurrencyLimiterExtension()->Find(max_concurrency.name().c_str());
CHECK(cl != NULL)
......
......@@ -26,7 +26,7 @@ namespace brpc {
class ConcurrencyLimiter : public Destroyable {
public:
ConcurrencyLimiter(): _max_concurrency(0) {}
ConcurrencyLimiter() : _max_concurrency(0) {}
// This method should be called each time a request comes in. It returns
// false when the concurrency reaches the upper limit, otherwise it
......@@ -56,6 +56,8 @@ public:
virtual ~ConcurrencyLimiter() {}
// Create ConcurrencyLimiter* and coredump if it fails.
// Caller is responsible for Destroy() the instance after usage.
static ConcurrencyLimiter* CreateConcurrencyLimiterOrDie(
const AdaptiveMaxConcurrency& max_concurrency);
......
......@@ -40,17 +40,16 @@ public:
// Returns true if the `max_concurrency' limit is not reached.
bool AddConcurrency(Controller* c) {
c->add_flag(Controller::FLAGS_ADDED_CONCURRENCY);
if (NULL != _server->_cl) {
c->add_flag(Controller::FLAGS_ADDED_CONCURRENCY);
return _server->_cl->OnRequested();
} else {
return true;
}
return true;
}
void RemoveConcurrency(const Controller* c) {
if (c->has_flag(Controller::FLAGS_ADDED_CONCURRENCY) &&
NULL != _server->_cl) {
if (c->has_flag(Controller::FLAGS_ADDED_CONCURRENCY)){
CHECK(_server->_cl != NULL)
_server->_cl->OnResponded(c->ErrorCode(), c->latency_us());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment