views:

442

answers:

1

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 inside another handler and I don't what invoker to use.

Thanks.

+3  A: 

IIUC, post will not call the function directly, ever, but postpone the call. dispatch will call it rightaway if the dispatch-caller was called from io_service itself, but queue it otherwise.

So, it depends on how the context for the call to post/dispatch looks, and if the given handler can be called straight away or not.

Marcus Lindblom