Skip to content

Created asio::experimental::awaitable_specific_ptr#1496

Open
corporategoth wants to merge 1 commit into
chriskohlhoff:masterfrom
corporategoth:prez/asio_awaitable_specific_ptr
Open

Created asio::experimental::awaitable_specific_ptr#1496
corporategoth wants to merge 1 commit into
chriskohlhoff:masterfrom
corporategoth:prez/asio_awaitable_specific_ptr

Conversation

@corporategoth

@corporategoth corporategoth commented Jun 18, 2024

Copy link
Copy Markdown

@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).

@vipcxj

vipcxj commented Dec 4, 2024

Copy link
Copy Markdown

I read your discussion in #1493. I think it would solve a lot of problems if we add a hook to the asio's awaitable context, such as issue in #1566

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.

2 participants