Skip to content

Deferred action on a closed socket #1822

Answered by uNetworkingAB
arroyo-pl asked this question in Q&A
Discussion options

You must be logged in to vote

Here's chatgpt reformulating it

You're describing a common design pattern in asynchronous programming with Boost.Asio, where the lifetime of operations and objects is managed using smart pointers. This approach works well to emulate cancellation by simply letting the owning shared pointer expire, which invalidates any weak pointers in flight. Here’s a breakdown of how and why this works:

The Design Rationale
Async Operations are Non-Cancellable: Boost.Asio doesn’t inherently support reliable cancellation of asynchronous operations. If you attempt to cancel an operation, it might still complete in some cases. The library’s design avoids guarantees for cancellation reliability to keep opera…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@uNetworkingAB
Comment options

@uNetworkingAB
Comment options

Answer selected by uNetworkingAB
@arroyo-pl
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants