Skip to content

Enhancement: strip off the std::map,use std::unordered_map instead #22

@YukunJ

Description

@YukunJ

Thanks to Cppers on reddit here.

Currently the Looper use std::map<int, std::unique_ptr<Connection>> to keep track of which connection's lifecycle is under its monitoring.

/**
 * This Looper acts as the executor on a single thread
 * adopt the philosophy of 'one looper per thread'
 * */
class Looper {
 public:
  ...
 private:
  ...
  std::map<int, std::unique_ptr<Connection>> connections_;
  ...
};

However, since we don't required the ordered property provided by std::map, a better performance could be achieved by using std::unordered_map. Typically given the fact that currently any access to this connections_ variable requires mutex for synchronization.

I plan to implement this feature shortly.

Yukun
Feb 07

Metadata

Metadata

Assignees

Labels

experimentalsome experimental results or changes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions