Похожие чаты

In ASIO, does an async operation start a new thread

and returns on call to the callback or is it blocked and returns after the callback returns?

9 ответов

13 просмотров

It doesn't start a thread and is not blocking. You send an object that handles connection whenever OS creates it. Your program continues running. https://www.boost.org/doc/libs/1_74_0/doc/html/boost_asio/overview/core/basics.html

Ihor
It doesn't start a thread and is not blocking. You...

How it is possible without thread? How async two different program works?

🖖- Автор вопроса
Ihor
It doesn't start a thread and is not blocking. You...

@JRandomGuy Thanks I really appreciate it

🖖- Автор вопроса
Cengizhan Pasaoglu
How it is possible without thread? How async two d...

Actually, it appears that if you run asio::io_service::run() in the main thread of execution, it blocks until all the operations are done You can decide to call asio::io_service::run() in a different thread

🖖
Actually, it appears that if you run asio::io_serv...

So, I am confused. I want it async without thread, it is not possible in this case because without thread it blocks until all operations done. But with new thread, async operation can be done. Did I understand right?

🖖- Автор вопроса
Cengizhan Pasaoglu
So, I am confused. I want it async without thread,...

No, you need to call asio::io_service::run() to get the result(s) and to pass it/them to the callback

Cengizhan Pasaoglu
So, I am confused. I want it async without thread,...

Async to me is just threads with an abstraction later on top. 🙂

Cengizhan Pasaoglu
So, I am confused. I want it async without thread,...

Me, writing a fiber implementation and a scheduler to solve that problem

Похожие вопросы

Обсуждают сегодня

Карта сайта