|
Boost Users : |
Subject: Re: [Boost-users] ASIO: Writing Composed Operations
From: Damian Jarek (damian.jarek93_at_[hidden])
Date: 2019-01-26 15:29:13
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 Fri, Jan 25, 2019 at 4:50 PM Cristian Morales Vega <cristian_at_[hidden]>
wrote:
> On Thu, 6 Dec 2018 at 23:59, Damian Jarek <damian.jarek93_at_[hidden]>
> 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?
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net