You can either check in the completion handler that `ex.running_in_this_thread() == true` or wrap the inner executor and use a thread-local variable to determine whether a current thread is running in the executor's context.
On Thu, 6 Dec 2018 at 23:59, Damian Jarek <damian.jarek93@gmail.com> wrote:
> Here's an example of what might happen if a composed operation doesn't maintain work guards properly:
> https://wandbox.org/permlink/aqsGDNJWTmFd7PdC
>
> Without the work_guard the coroutine never completes. If you add the work_guard, everything works correctly.
If I were to do something stupid like
https://wandbox.org/permlink/sIpX20mQdaHgjESz
- Hide executor_type making it private
- Use the handler executor type for the work guard
What would be the best way to unit test async_foo() to detect the problems?
I guess I could derive from io_context to get the steady_timer to use
an intermediate executor that would forward everything to the
io_context::get_executor but keeping record of the work count, and
bind a similar fake executor to check the dispatch calls. But there
may be a more clever/simpler way?