Weston Pace created ARROW-12285:
-----------------------------------
Summary: [C++] Create a better mechanism for async state management
Key: ARROW-12285
URL: https://issues.apache.org/jira/browse/ARROW-12285
Project: Apache Arrow
Issue Type: Improvement
Components: C++
Reporter: Weston Pace
It can be a bit tricky keeping everything alive in an async context. This is
an umbrella issue for discussion and brainstorming of ideas.
For example, a nursery blocks until all underlying tasks have finished. This
allows things defined at the top level of the nursery to be global state shared
by reference across all tasks.
A common approach in use right now is to wrap state in a shared pointer and
pass that state by copy to all callbacks but this might involve a lot of shared
pointer copies.
Another approach could be to define a method like `Future<T>
AsyncBind(function<Future<T>(S*)>>, shared_ptr<S>)` which guarantees the S* is
valid until the future completes.
Those approaches also might help futures but then not be able to help async
generators, especially if that generator is passed back to user code. In that
case it might be helpful to have something like...
AsyncGenerator<T> AddFinallyCallback(AsyncGenerator<T>, function<void()>)
...or...
AsyncGenerator<T> BindToGenerator(function<AsyncGenerator<T>(S*)>,
std::shared_ptr<S>)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)