Boost logo

Boost Users :

Subject: Re: [Boost-users] ASIO: custom service which works with spawn/yield
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2018-07-25 17:12:54


On Wed, Jul 25, 2018 at 7:25 AM, Cristian Morales Vega via Boost-users
<boost-users_at_[hidden]> wrote:
> The following simplified sample shows the problem:

First of all thank you for posting a minimal, complete, and verifiable example.

It looks like your implementation of async_method() is missing one or
two executor_work_guard objects:

Per N4734[1] 13.2.7.10 Outstanding Work [async.reqmts.async.work]

    1. Until the asynchronous operation has completed, the
asynchronous operation shall maintain:

    (1.1) — an object work1 of type executor_work_guard, initialized
as work1(ex1), and where work1.owns_work() == true; and

    (1.2) — an object work2 of type executor_work_guard, initialized
as work2(ex2), and where work2.owns_work() == true.

I don't think you can get away with just calling `post` from
`async_method` you need to write a "real" composed operation class
with all of the bells and whistles including forwarding of the
associated executor and associated allocator. In this class you can
store the two required executor_work_guard objects as data members.

A tutorial for writing composed operations may be found here:

<https://www.boost.org/doc/libs/1_67_0/libs/beast/doc/html/beast/using_io/writing_composed_operations.html>

Thanks

[1] <http://cplusplus.github.io/networking-ts/draft.pdf>


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