bshoshany / thread-pool

BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
MIT License
2.21k stars 253 forks source link

[REQ] Rename Timer into TimeMeasure and providing a real timer class? #150

Closed faywong closed 5 months ago

faywong commented 5 months ago

Describe the new feature

Rename Timer into TimeMeasure and providing a real timer class?

Code example

Just like the timer usage of boost.asio lib:


 void print()
  {
    if (count_ < 5)
    {
      std::cout << count_ << std::endl;
      ++count_;

      timer_.expires_at(timer_.expiry() + boost::asio::chrono::seconds(1));
      timer_.async_wait(std::bind(&printer::print, this));
    }
  }

private:
  boost::asio::steady_timer timer_;
  int count_;
};

Additional information

Include any additional information here.

bshoshany commented 5 months ago

Hi @faywong and thanks for the feature request!

I don't think it makes sense to rename the timer class and replace it with a different feature at this point, since that would confuse users who are using that class to do performance tests. However, I would consider adding a new class with a different name.

Unfortunately, I'm not too familiar with boost.asio. Give me some time to look into it and see if this functionality would be beneficial for my package. This might take a few weeks since I have some other projects going on right now. Thanks again :)