[http_server] Simplify DRT node and table #132
Draft
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
When I see the
std::vecotr<std::shared_ptr<drt_node>>andstd::vector<std::shared_ptr<std::string>>as thedrt_nodeanddynamic_routing_table's members respectively, I cannot help wondering why theshared_ptr<T>are needed here. Later I realized the instance of the DRT table is allowed to copy therefore we need to keep its objects being shared across all instances. Somehow I still think it is a waste to haveshared_ptr<T>manage each small object.This PR includes
unordered_set<string>to keep the strings other thanstd::vector<std::shared_ptr<std::string>>.unordered_set<string>is more straightforward and able to get rid of redundant duplicates automatically.drt_node_poolwrapping thevector<unique_ptr<drt_node>>and its instance is shared across all instances ofdrt_nodeto manage the lifetime of new drt_node instances.dynamic_routing_tableis to hold oneshared_ptr<dynamic_routing_table_data>to let one shared_ptr manage one big object other than multiple shared_ptrs manage multple small objects.This PR is posted as draft to let @matt-42 have a review first. Will squash to one single commit before final merge.