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

Created asio::experimental::awaitable_specific_ptr #1496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

corporategoth
Copy link

@corporategoth corporategoth commented Jun 18, 2024

@chriskohlhoff I am trying to bring coroutines in parity with threads somewhat, specifically, trying to replicate boost::thread_specific_ptr, but for coroutines (awaitables).

This can be hacked externally with a lot of effort, including having to create your own executor, and make sure you use it everywhere, and then use a different awaitable class and use_awaitable. But it's hacky and relies on the user to do a lot of things, and remember to do them always. It would be like if boost::thread_specific_ptr only worked if they use my_thread instead of std::thread to launch their thread.

This creates an implementation of awaitable_specific_ptr that works with coroutines, and is automatic for any awaitable, so the user doesn't have to do anything except USE awaitable_specific_ptr - it's automatic.

Given there is no real "awaitable ID" that is externally accessible to help implement this externally, this would be a large boon for being able have an equivalent of thread-specific storage (for example for use with logging contexts, etc).

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

Successfully merging this pull request may close these issues.

1 participant