facebookexperimental / facebookexperimental/libunifex

(Is there already) support for async stream

Open
#586 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.7k
Forks
210
PR merge metrics
No merged PRs in 30d

Description

Hi, I also commented on #507 as it seems related (at least to someone not too familiar with S/R yet).

A little bit of context of what I want: I am looking for something that represents an async stream, to sketch out an example:

```C++
unifex::task getFooSum(/* some params here */)
{
auto request = /* build request from params */

// This range of responses is filled from the underlying RPC framework, responses are arriving on
// a separate thread (what we've termed "the callback thread" internally.
auto rangeOfMultipartResponses = someRpcClient->sendRequest(request);
auto fooValueSum = rangeOfMultipartResponses
unifex::reduce_stream(0, [](auto resp){ resp.fooValue(); });
co_return co_await fooValueSum;
}
```

Is this something that the generic `range_stream` would support OR we need to build our own stream adapter? And isn't this something generic enough to be present in `libunifex`? Basically something like `cppcoro::async_generator` that speaks the stream protocol? I have seen `cppcoro::async_generator` being mentioned in the docs, but wasn't able to find anything that can support that functionality here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.