[incubator-brpc] branch master updated: FlatMap's value supports unique_ptr

2022-12-12 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 50e41d0a FlatMap's value supports unique_ptr
50e41d0a is described below

commit 50e41d0a0b36634b4f275d2bc204ed3ec908bcde
Author: gejun.0 
AuthorDate: Tue Dec 13 10:47:38 2022 +0800

FlatMap's value supports unique_ptr
---
 src/butil/containers/flat_map.h | 8 
 src/butil/containers/flat_map_inl.h | 8 
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/butil/containers/flat_map.h b/src/butil/containers/flat_map.h
index 6f2deafe..6789c3c7 100644
--- a/src/butil/containers/flat_map.h
+++ b/src/butil/containers/flat_map.h
@@ -361,11 +361,15 @@ public:
 // ^^^
 const K& first_ref() const { return _key; }
 T& second_ref() { return _value; }
+T&& second_movable_ref() { return std::move(_value); }
 value_type& value_ref() { return *reinterpret_cast(this); }
 inline static const K& first_ref_from_value(const value_type& v)
 { return v.first; }
 inline static const T& second_ref_from_value(const value_type& v)
 { return v.second; }
+inline static T&& second_movable_ref_from_value(value_type& v)
+{ return std::move(v.second); }
+
 private:
 const K _key;
 T _value;
@@ -378,12 +382,16 @@ public:
 explicit FlatMapElement(const K& k) : _key(k) {}
 const K& first_ref() const { return _key; }
 FlatMapVoid& second_ref() { return second_ref_from_value(_key); }
+FlatMapVoid& second_movable_ref() { return second_ref(); }
 value_type& value_ref() { return _key; }
 inline static const K& first_ref_from_value(value_type& v) { return v; }
 inline static FlatMapVoid& second_ref_from_value(value_type&) {
 static FlatMapVoid dummy;
 return dummy;
 }
+inline static const FlatMapVoid& second_movable_ref_from_value(value_type& 
v) {
+return second_ref_from_value(v);
+}
 private:
 K _key;
 };
diff --git a/src/butil/containers/flat_map_inl.h 
b/src/butil/containers/flat_map_inl.h
index ad5598c2..e98c88b5 100644
--- a/src/butil/containers/flat_map_inl.h
+++ b/src/butil/containers/flat_map_inl.h
@@ -394,7 +394,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 }
 if (_eql(first_node.element().first_ref(), key)) {
 if (old_value) {
-*old_value = first_node.element().second_ref();
+*old_value = first_node.element().second_movable_ref();
 }
 if (first_node.next == NULL) {
 first_node.element().~Element();
@@ -420,7 +420,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 first_node.next = p->next;
 const_cast<_K&>(first_node.element().first_ref()) =
 p->element().first_ref();
-first_node.element().second_ref() = p->element().second_ref();
+first_node.element().second_ref() = 
p->element().second_movable_ref();
 p->element().~Element();
 _pool.back(p);
 }
@@ -432,7 +432,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 while (p) {
 if (_eql(p->element().first_ref(), key)) {
 if (old_value) {
-*old_value = p->element().second_ref();
+*old_value = p->element().second_movable_ref();
 }
 last_p->next = p->next;
 p->element().~Element();
@@ -616,7 +616,7 @@ bool FlatMap<_K, _T, _H, _E, _S>::resize(size_t nbucket2) {
 }
 for (iterator it = begin(); it != end(); ++it) {
 new_map[Element::first_ref_from_value(*it)] = 
-Element::second_ref_from_value(*it);
+Element::second_movable_ref_from_value(*it);
 }
 new_map.swap(*this);
 return true;


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] wwbmmm commented on issue #2048: 用户态tcp实现是否会开源呢?

2022-12-12 Thread GitBox


wwbmmm commented on issue #2048:
URL: 
https://github.com/apache/incubator-brpc/issues/2048#issuecomment-1347654708

   目前已经线上使用,暂时没有开源计划


-- 
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-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] l495386774 opened a new issue, #2048: 用户态tcp实现是否会开源呢?

2022-12-12 Thread GitBox


l495386774 opened a new issue, #2048:
URL: https://github.com/apache/incubator-brpc/issues/2048

   在7月份的视频中看到介绍说brpc实现了用户态tcp、去掉了bthread,目前是否已经上线使用?这个feature是否会开源呢?
   
![image](https://user-images.githubusercontent.com/19951954/207209476-eb8bec28-1444-4f90-a89b-c69eac029502.png)
   


-- 
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-unsubscr...@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] wwbmmm commented on issue #2042: 普通线程中调用bthread_start_background100次,在函数中打印对应的stack 100次执行的都是一个值,对应的cur_tid都是0,我打印前是取出来对应的值赋值局部变量打印的

2022-12-12 Thread GitBox


wwbmmm commented on issue #2042:
URL: 
https://github.com/apache/incubator-brpc/issues/2042#issuecomment-1346251636

   @jiangdongzi 试试PR #2047 能否解决这个问题


-- 
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-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jiangdongzi commented on issue #2046: 使用brpc作grpc客户端发请求时是否可以带上域名呢

2022-12-12 Thread GitBox


jiangdongzi commented on issue #2046:
URL: 
https://github.com/apache/incubator-brpc/issues/2046#issuecomment-1346192593

   > 用controller.http_request().uri().set_host()可以吗?
   
   试了下, 没有加上,  也试了下 "cntl.http_request().SetHeader("Host, "xx") 也不行 


-- 
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-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] wwbmmm opened a new pull request, #2047: Keep bthread TaskGroup abi compatible with NDEBUG macro

2022-12-12 Thread GitBox


wwbmmm opened a new pull request, #2047:
URL: https://github.com/apache/incubator-brpc/pull/2047

   ### What problem does this PR solve?
   
   Issue Number: #2042
   
   Problem Summary: bthread::TaskGroup add a new member _sched_recursive_guard 
if NDEBUG is not defined, this cause abi incompatible.
   
   ### What is changed and the side effects?
   
   Changed: define the _sched_recursive_guard whether NDEBUG is defined or not
   
   Side effects:
   - Performance effects(性能影响): No
   
   - Breaking backward compatibility(向后兼容性): No
   
   ---
   ### 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](../../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-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org