This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Please support Coroutines TS in C++


(repeated, forgot to reply to mailing list)

Xi Ruoyao misses completely the point!

The amount of error prone boilerplate code, that the programmer would
have to write, is huge. See examples in the excellent presentation
"C++ coroutines: a negative overhead abstraction"
https://www.slideshare.net/SergeyPlatonov/gor-nishanov-c-coroutines-a-negative-overhead-abstraction
Video: https://www.youtube.com/watch?v=_fu0gx-xseY

What one can have with a coroutine library, are stackfull coroutines.
But they are not really useful. Not very scalable. The simplification
of programming has a high cost.

With stackless coroutines, one can combine the simplicity of
sequential programming, with the scalability and efficiency of
asynchronous programming.

Did you ever read Linux kernel code? There is a lot of hand written
code that tries to achieve a sequence of actions using chained
callbacks:

void A()
{
  a1();
  when event E1 happens, run B
}

void B()
{
  b1();
  when event E2 happends, run C
}

void C()
{
 c1()
}

with Coroutines TS this is turned into

void A()
{
  a1();
  co_await E1;
  b1();
  co_await E2;
  c1();
}

but have the same efficiency and scalability of asynchronous code.

On Sat, Aug 19, 2017 at 5:49 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> See the thread on gcc-help:
> https://gcc.gnu.org/ml/gcc-help/2017-08/msg00045.html
>
>
>
> On 19 August 2017 at 14:09, Ramón García <ramon.garcia.f@gmail.com> wrote:
>> ping.
>>
>> On Tue, Aug 15, 2017 at 2:21 PM, Ramón García <ramon.garcia.f@gmail.com> wrote:
>>> Hello,
>>>
>>> Please consider supporting the Coroutines TS in GNU C++.
>>>
>>> It is really important to make asynchronous programming usable.
>>>
>>> Modern programs should be scalable to use the performance of multicore
>>> processors. Stackless coroutines allow the programmer to scale to
>>> millions of asynchronous requests. But without the primitives in the
>>> Concurrency TS, chaining the result of an asynchronous computation to
>>> the next step, one must program a chain of callbacks. It becomes
>>> quickly unusable.
>>>
>>> The promise/future, as specified in the concurrency TS, (that is, with
>>> the function future::then for chaining a callback to the completion of
>>> the future) make asynchronous programming somewhat more usable.
>>> Unfortunately, almost no C++ library shipped supports future with
>>> then.
>>>
>>> This is an excellent explanation of the Coroutines TS:
>>>
>>> https://www.slideshare.net/SergeyPlatonov/gor-nishanov-c-coroutines-a-negative-overhead-abstraction
>>>
>>> Both Visual C++ 2017 and CLANG (SVN version) support the Coroutines
>>> TS. Please consider it.
>>>
>>> I saw that someone started an attempt at implementing it:
>>> https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00435.html but there
>>> were no replies.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]