Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a second constructor to avoid comparing size_t (unsigned int) and int #70

Merged
merged 1 commit into from Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion io_context/include/io_context/io_context.hpp
Expand Up @@ -59,7 +59,8 @@ struct thread_group
class IoContext
{
public:
explicit IoContext(size_t threads_count = -1);
IoContext();
explicit IoContext(size_t threads_count);
~IoContext();

IoContext(const IoContext &) = delete;
Expand Down
7 changes: 3 additions & 4 deletions io_context/src/io_context.cpp
Expand Up @@ -26,15 +26,14 @@ namespace drivers
namespace common
{

IoContext::IoContext()
: IoContext(std::thread::hardware_concurrency()) {}

IoContext::IoContext(size_t threads_count)
: m_ios(new asio::io_service()),
m_work(new asio::io_service::work(ios())),
m_ios_thread_workers(new drivers::common::thread_group())
{
if (threads_count == size_t(-1)) {
threads_count = std::thread::hardware_concurrency();
}

for (size_t i = 0; i < threads_count; ++i) {
m_ios_thread_workers->create_thread(
[this]() {
Expand Down