Skip to content

Commit

Permalink
example: operations/composed_6: also free delay_timer_
Browse files Browse the repository at this point in the history
Also the delay_timer_ member should be freed before calling the
user-supplied completion handler (as in the composed_7 and composed_8
examples).

Signed-off-by: Christian Eggers <[email protected]>
  • Loading branch information
ceggers-arri committed Jul 4, 2024
1 parent 4bcd6d5 commit c95e693
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions asio/src/examples/cpp11/operations/composed_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ struct async_write_message_initiation
// We no longer have any future work coming for the I/O executor.
io_work_.reset();

// Deallocate the encoded message before calling the user-supplied
// completion handler.
// Deallocate the encoded message and delay timer before calling the
// user-supplied completion handler.
encoded_message_.reset();
delay_timer_.reset();

// Call the user-supplied handler with the result of the operation.
handler_(error);
Expand Down
5 changes: 3 additions & 2 deletions asio/src/examples/cpp14/operations/composed_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ auto async_write_messages(tcp::socket& socket,
// We no longer have any future work coming for the I/O executor.
io_work_.reset();

// Deallocate the encoded message before calling the user-supplied
// completion handler.
// Deallocate the encoded message and delay timer before calling the
// user-supplied completion handler.
encoded_message_.reset();
delay_timer_.reset();

// Call the user-supplied handler with the result of the operation.
handler_(error);
Expand Down
5 changes: 3 additions & 2 deletions asio/src/examples/cpp20/operations/composed_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ auto async_write_messages(tcp::socket& socket,
// We no longer have any future work coming for the I/O executor.
io_work_.reset();

// Deallocate the encoded message before calling the user-supplied
// completion handler.
// Deallocate the encoded message and delay timer before calling the
// user-supplied completion handler.
encoded_message_.reset();
delay_timer_.reset();

// Call the user-supplied handler with the result of the operation.
handler_(error);
Expand Down

0 comments on commit c95e693

Please sign in to comment.