Boost asio io_service dispatch vs post

后端 未结 2 831
花落未央
花落未央 2020-12-23 20:29

Can anyone tell me the difference between io_service dispatch and post? It was not clear to me what is more suitable for my problem.

I need to invoke a handler insid

2条回答
  •  伪装坚强ぢ
    2020-12-23 21:08

    see this blog entry:
    To post or to dispatch? - This Thread

    Running the application we'll see the difference between posting and dispatching. Since it could do it, dispatch() would execute fB() directly, so we'll see it runs in the current thread, and synchronously. On the other side, post() would ask to io_service to do the job, asynchronously in another thread, and it immediately returns the control to the caller.

提交回复
热议问题