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

write free function #223

Merged
merged 2 commits into from
Jan 29, 2024
Merged

write free function #223

merged 2 commits into from
Jan 29, 2024

Conversation

turuslan
Copy link
Contributor

@turuslan turuslan commented Nov 9, 2023

  • (Refactor read write some #206)
  • replace Writer::write with write/writeReturnSize
    • writeReturnSize doesn't change callback type to reduce changes to review
      • old usages may be simplified/refactored later in other pr's
  • remove Writer::write
    • Writer::write can't get shared_ptr from this
      • enable_shared_from_this would conflict (Reader, Writer, user class)

Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
std::span(data, ssize_t(writing_bytes_)),
writing_bytes_,

BytesIn span{*buffer};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we create span explicitly?

Copy link
Contributor Author

@turuslan turuslan Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They moved buffer into lambda, so created span before move.
(This old code may be unstable, std::function/boost::asio::io_context may copy lambda and duplicate/invalidate buffer, sptr<lambda>/sptr<buffer> would be better; #226)

buffer != (null, 0)
span = span(buffer)
lambda.buffer = move(buffer)
buffer == (null, 0)
write(span, lambda)

@turuslan turuslan merged commit 06adba2 into master Jan 29, 2024
2 of 5 checks passed
@turuslan turuslan deleted the refactor/write branch January 29, 2024 13:43
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.

3 participants