Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions io_context/include/io_context/io_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class IoContext
IoContext(const IoContext &) = delete;
IoContext & operator=(const IoContext &) = delete;

asio::io_service & ios() const;
asio::io_context & ios() const;

bool isServiceStopped();
uint32_t serviceThreadCount();
Expand All @@ -76,12 +76,12 @@ class IoContext
template<class F>
void post(F f)
{
ios().post(f);
asio::post(ios(), f);
}

private:
std::shared_ptr<asio::io_service> m_ios;
std::shared_ptr<asio::io_service::work> m_work;
std::shared_ptr<asio::io_context> m_ios;
std::shared_ptr<asio::executor_work_guard<asio::io_context::executor_type>> m_work;
std::shared_ptr<drivers::common::thread_group> m_ios_thread_workers;
};

Expand Down
8 changes: 4 additions & 4 deletions io_context/src/io_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ 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(new asio::io_context()),
m_work(new asio::executor_work_guard<asio::io_context::executor_type>(ios().get_executor())),
m_ios_thread_workers(new drivers::common::thread_group())
{
for (size_t i = 0; i < threads_count; ++i) {
Expand All @@ -51,7 +51,7 @@ IoContext::~IoContext()
waitForExit();
}

asio::io_service & IoContext::ios() const
asio::io_context & IoContext::ios() const
{
return *m_ios;
}
Expand All @@ -69,7 +69,7 @@ uint32_t IoContext::serviceThreadCount()
void IoContext::waitForExit()
{
if (!ios().stopped()) {
ios().post([&]() {m_work.reset();});
asio::post(ios(), [&]() {m_work.reset();});
}

ios().stop();
Expand Down
Loading