darion-yaphet commented on code in PR #3490:
URL: https://github.com/apache/brpc/pull/3490#discussion_r3869501859
##########
src/bthread/task_control.h:
##########
@@ -171,10 +172,14 @@ friend bthread_t init_for_pthread_stack_trace();
bvar::PassiveStatus<std::string> _status;
bvar::Adder<int64_t> _nbthreads;
- std::vector<bvar::Adder<int64_t>*> _tagged_nworkers;
- std::vector<bvar::PassiveStatus<double>*> _tagged_cumulated_worker_time;
- std::vector<bvar::PerSecond<bvar::PassiveStatus<double>>*>
_tagged_worker_usage_second;
- std::vector<bvar::Adder<int64_t>*> _tagged_nbthreads;
+ std::vector<std::unique_ptr<bvar::Adder<int64_t>>> _tagged_nworkers;
Review Comment:
> Wouldn't it be better to use `std::vector<bvar::Adder<int64_t>>`?
bvar::Adder inherits bvar::Variable, which is non-copyable, and Adder is
also effectively non-movable. A std::vector<bvar::Adder<int64_t>> must be able
to relocate elements when it grows, so it cannot safely support this pattern.
More importantly, each exposed bvar must retain a stable address.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]