-
Notifications
You must be signed in to change notification settings - Fork 42
Removes async_append_some #283
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* Copyright (c) 2018-2025 Marcelo Zimbres Silva ([email protected]) | ||
* | ||
* Distributed under the Boost Software License, Version 1.0. (See | ||
* accompanying file LICENSE.txt) | ||
*/ | ||
|
||
#ifndef BOOST_REDIS_READ_BUFFER_HPP | ||
#define BOOST_REDIS_READ_BUFFER_HPP | ||
|
||
#include <boost/core/span.hpp> | ||
#include <boost/system/error_code.hpp> | ||
|
||
#include <cstddef> | ||
#include <string_view> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace boost::redis::detail { | ||
|
||
class read_buffer { | ||
public: | ||
using span_type = span<char>; | ||
|
||
// See config.hpp for the meaning of these parameters. | ||
struct config { | ||
std::size_t read_buffer_append_size = 4096u; | ||
std::size_t max_read_size = static_cast<std::size_t>(-1); | ||
}; | ||
|
||
[[nodiscard]] | ||
auto prepare_append() -> system::error_code; | ||
|
||
[[nodiscard]] | ||
auto get_append_buffer() noexcept -> span_type; | ||
|
||
void commit_append(std::size_t read_size); | ||
|
||
[[nodiscard]] | ||
auto get_committed_buffer() const noexcept -> std::string_view; | ||
|
||
[[nodiscard]] | ||
auto get_committed_size() const noexcept -> std::size_t; | ||
anarthal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void clear(); | ||
|
||
// Consume committed data. | ||
auto consume_committed(std::size_t size) -> std::size_t; | ||
|
||
void reserve(std::size_t n); | ||
|
||
friend bool operator==(read_buffer const& lhs, read_buffer const& rhs); | ||
|
||
friend bool operator!=(read_buffer const& lhs, read_buffer const& rhs); | ||
|
||
void set_config(config const& cfg) noexcept { cfg_ = cfg; }; | ||
|
||
private: | ||
config cfg_ = config{}; | ||
std::vector<char> buffer_; | ||
std::size_t append_buf_begin_ = 0; | ||
}; | ||
|
||
} // namespace boost::redis::detail | ||
|
||
#endif // BOOST_REDIS_READ_BUFFER_HPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
|
||
#ifndef BOOST_REDIS_READER_FSM_HPP | ||
#define BOOST_REDIS_READER_FSM_HPP | ||
|
||
#include <boost/redis/detail/multiplexer.hpp> | ||
|
||
#include <boost/asio/cancellation_type.hpp> | ||
|
@@ -16,6 +15,8 @@ | |
|
||
namespace boost::redis::detail { | ||
|
||
class read_buffer; | ||
|
||
class reader_fsm { | ||
public: | ||
struct action { | ||
|
@@ -30,11 +31,11 @@ class reader_fsm { | |
}; | ||
|
||
type type_ = type::setup_cancellation; | ||
std::size_t push_size_ = 0; | ||
std::size_t push_size_ = 0u; | ||
system::error_code ec_ = {}; | ||
}; | ||
|
||
explicit reader_fsm(multiplexer& mpx) noexcept; | ||
explicit reader_fsm(read_buffer& rbuf, multiplexer& mpx) noexcept; | ||
|
||
action resume( | ||
std::size_t bytes_read, | ||
|
@@ -43,6 +44,7 @@ class reader_fsm { | |
|
||
private: | ||
int resume_point_{0}; | ||
read_buffer* read_buffer_ = nullptr; | ||
action action_after_resume_; | ||
action::type next_read_type_ = action::type::append_some; | ||
mzimbres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
multiplexer* mpx_ = nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As written, this yields to a dangling pointer after a connection is moved. I suggest wrapping every member in |
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.