You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "chenBright (via GitHub)" <gi...@apache.org> on 2025/01/02 12:57:29 UTC
[PR] Support variable arguments for ResourcePool and ObjectPool (brpc)
chenBright opened a new pull request, #2859:
URL: https://github.com/apache/brpc/pull/2859
### What problem does this PR solve?
Issue Number:
Problem Summary:
### What is changed and the side effects?
Changed:
Side effects:
- Performance effects(性能影响):
- Breaking backward compatibility(向后兼容性):
---
### Check List:
- Please make sure your changes are compilable(请确保你的更改可以通过编译).
- When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
- Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Support variable arguments for ResourcePool and ObjectPool (brpc)
Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm merged PR #2859:
URL: https://github.com/apache/brpc/pull/2859
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Support variable arguments for ResourcePool and ObjectPool (brpc)
Posted by "ivanallen (via GitHub)" <gi...@apache.org>.
ivanallen commented on code in PR #2859:
URL: https://github.com/apache/brpc/pull/2859#discussion_r1901464617
##########
src/butil/object_pool.h:
##########
@@ -75,21 +75,10 @@ template <typename T> inline bool local_pool_free_empty() {
}
// Get an object typed |T|. The object should be cleared before usage.
-// NOTE: T must be default-constructible.
-template <typename T> inline T* get_object() {
- return ObjectPool<T>::singleton()->get_object();
-}
-
-// Get an object whose constructor is T(arg1)
-template <typename T, typename A1>
-inline T* get_object(const A1& arg1) {
- return ObjectPool<T>::singleton()->get_object(arg1);
-}
-
-// Get an object whose constructor is T(arg1, arg2)
-template <typename T, typename A1, typename A2>
-inline T* get_object(const A1& arg1, const A2& arg2) {
- return ObjectPool<T>::singleton()->get_object(arg1, arg2);
+// NOTE: If there are no arguments, T must be default-constructible.
+template <typename T, typename... Args>
+inline T* get_object(Args... args) {
Review Comment:
这里应该使用 universal reference?
```c++
inline T* get_object(Args&&... args) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Support variable arguments for ResourcePool and ObjectPool (brpc)
Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on code in PR #2859:
URL: https://github.com/apache/brpc/pull/2859#discussion_r1901494811
##########
src/butil/object_pool.h:
##########
@@ -75,21 +75,10 @@ template <typename T> inline bool local_pool_free_empty() {
}
// Get an object typed |T|. The object should be cleared before usage.
-// NOTE: T must be default-constructible.
-template <typename T> inline T* get_object() {
- return ObjectPool<T>::singleton()->get_object();
-}
-
-// Get an object whose constructor is T(arg1)
-template <typename T, typename A1>
-inline T* get_object(const A1& arg1) {
- return ObjectPool<T>::singleton()->get_object(arg1);
-}
-
-// Get an object whose constructor is T(arg1, arg2)
-template <typename T, typename A1, typename A2>
-inline T* get_object(const A1& arg1, const A2& arg2) {
- return ObjectPool<T>::singleton()->get_object(arg1, arg2);
+// NOTE: If there are no arguments, T must be default-constructible.
+template <typename T, typename... Args>
+inline T* get_object(Args... args) {
Review Comment:
是的,搞漏了,我提个PR修一下。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org