| 753 | } |
| 754 | |
| 755 | bool Server::CreateConcurrencyLimiter(const AdaptiveMaxConcurrency& amc, |
| 756 | ConcurrencyLimiter** out) { |
| 757 | if (amc.type() == AdaptiveMaxConcurrency::UNLIMITED) { |
| 758 | *out = NULL; |
| 759 | return true; |
| 760 | } |
| 761 | const ConcurrencyLimiter* cl = |
| 762 | ConcurrencyLimiterExtension()->Find(amc.type().c_str()); |
| 763 | if (cl == NULL) { |
| 764 | LOG(ERROR) << "Fail to find ConcurrencyLimiter by `" << amc.value() << "'"; |
| 765 | return false; |
| 766 | } |
| 767 | ConcurrencyLimiter* cl_copy = cl->New(amc); |
| 768 | if (cl_copy == NULL) { |
| 769 | LOG(ERROR) << "Fail to new ConcurrencyLimiter"; |
| 770 | return false; |
| 771 | } |
| 772 | *out = cl_copy; |
| 773 | return true; |
| 774 | } |
| 775 | |
| 776 | |
| 777 | static AdaptiveMaxConcurrency g_default_max_concurrency_of_method(0); |