Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] Create a better mechanism for async state management #28091

Open
asfimport opened this issue Apr 7, 2021 · 0 comments
Open

[C++] Create a better mechanism for async state management #28091

asfimport opened this issue Apr 7, 2021 · 0 comments

Comments

@asfimport
Copy link

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 AddFinallyCallback(AsyncGenerator, function<void()>)

...or...

AsyncGenerator BindToGenerator(function<AsyncGenerator(S*)>, std::shared_ptr)

Reporter: Weston Pace / @westonpace

Note: This issue was originally created as ARROW-12285. Please see the migration documentation for further details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant