mirror of
https://github.com/monero-project/monero.git
synced 2025-05-13 06:32:14 -04:00
Use byte_slice for sending zmq messages - removes data copy within zmq
This commit is contained in:
parent
378cdeaeae
commit
da99157462
11 changed files with 138 additions and 27 deletions
|
@ -42,7 +42,12 @@ namespace epee
|
|||
|
||||
struct release_byte_slice
|
||||
{
|
||||
void operator()(byte_slice_data*) const noexcept;
|
||||
//! For use with `zmq_message_init_data`, use second arg for buffer pointer.
|
||||
static void call(void*, void* ptr) noexcept;
|
||||
void operator()(byte_slice_data* ptr) const noexcept
|
||||
{
|
||||
call(nullptr, ptr);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Inspired by slices in golang. Storage is thread-safe reference counted,
|
||||
|
@ -140,6 +145,9 @@ namespace epee
|
|||
\throw std::out_of_range If `size() < end`.
|
||||
\return Slice starting at `data() + begin` of size `end - begin`. */
|
||||
byte_slice get_slice(std::size_t begin, std::size_t end) const;
|
||||
|
||||
//! \post `empty()` \return Ownership of ref-counted buffer.
|
||||
std::unique_ptr<byte_slice_data, release_byte_slice> take_buffer() noexcept;
|
||||
};
|
||||
} // epee
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue