Skip to content

write free function#223

Merged
turuslan merged 2 commits intomasterfrom
refactor/write
Jan 29, 2024
Merged

write free function#223
turuslan merged 2 commits intomasterfrom
refactor/write

Conversation

@turuslan
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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