mirror of
https://github.com/monero-project/monero.git
synced 2025-08-06 04:44:20 -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
|
@ -49,12 +49,16 @@ namespace epee
|
|||
std::atomic<std::size_t> ref_count;
|
||||
};
|
||||
|
||||
void release_byte_slice::operator()(byte_slice_data* ptr) const noexcept
|
||||
void release_byte_slice::call(void*, void* ptr) noexcept
|
||||
{
|
||||
if (ptr && --(ptr->ref_count) == 0)
|
||||
if (ptr)
|
||||
{
|
||||
ptr->~byte_slice_data();
|
||||
free(ptr);
|
||||
byte_slice_data* self = static_cast<byte_slice_data*>(ptr);
|
||||
if (--(self->ref_count) == 0)
|
||||
{
|
||||
self->~byte_slice_data();
|
||||
free(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,4 +210,11 @@ namespace epee
|
|||
return {};
|
||||
return {storage_.get(), {portion_.begin() + begin, end - begin}};
|
||||
}
|
||||
|
||||
std::unique_ptr<byte_slice_data, release_byte_slice> byte_slice::take_buffer() noexcept
|
||||
{
|
||||
std::unique_ptr<byte_slice_data, release_byte_slice> out{std::move(storage_)};
|
||||
portion_ = nullptr;
|
||||
return out;
|
||||
}
|
||||
} // epee
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue