Skip to content

Commit 7469719

Browse files
committed
iostream: Remove write()-s of packet/scattered_message from new API level
Since we're introducing the new level anyway, it's good to instantly switch all users into using the write(span) for zero-copy IO. The write(temporary_buffer) is kept for convenience. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
1 parent 29b07e5 commit 7469719

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

apps/memcached/memcache.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,8 @@ class ascii_protocol {
917917
scattered_message<char> msg;
918918
this_type::append_item<WithVersion>(msg, std::move(item));
919919
msg.append_static(msg_end);
920-
return out.write(std::move(msg));
920+
std::vector<temporary_buffer<char>> bufs = std::move(msg).release().release();
921+
return out.write(std::span<temporary_buffer<char>>(bufs));
921922
});
922923
} else {
923924
_items.clear();
@@ -931,7 +932,8 @@ class ascii_protocol {
931932
append_item<WithVersion>(msg, std::move(item));
932933
}
933934
msg.append_static(msg_end);
934-
return out.write(std::move(msg));
935+
std::vector<temporary_buffer<char>> bufs = std::move(msg).release().release();
936+
return out.write(std::span<temporary_buffer<char>>(bufs));
935937
});
936938
}
937939
}

include/seastar/core/iostream-impl.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ future<> output_stream<CharType>::write(temporary_buffer<CharType> p) noexcept {
145145
}
146146
}
147147

148+
#if SEASTAR_API_LEVEL < 9
148149
template<typename CharType>
149150
future<> output_stream<CharType>::write(net::packet p) noexcept {
150151
try {
@@ -159,6 +160,7 @@ template<typename CharType>
159160
future<> output_stream<CharType>::write(scattered_message<CharType> msg) noexcept {
160161
return write(std::move(msg).release());
161162
}
163+
#endif
162164

163165
template <typename CharType>
164166
future<temporary_buffer<CharType>>

include/seastar/core/iostream.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,13 @@ public:
512512
/// Writes the given string into the buffer
513513
future<> write(const std::basic_string<char_type>& s) noexcept;
514514

515+
#if SEASTAR_API_LEVEL < 9
515516
/// Appends the packet as zero-copy buffer
516517
future<> write(net::packet p) noexcept;
517518
/// Appends the scattered message as zero-copy buffer
518519
future<> write(scattered_message<char_type> msg) noexcept;
520+
#endif
521+
519522
/// Appends the temporary buffer as zero-copy buffer
520523
future<> write(temporary_buffer<char_type>) noexcept;
521524
/// Appends a bunch of buffers as zero-copy

0 commit comments

Comments
 (0)