mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Use wpi::span instead of wpi::ArrayRef across all libraries (#3414)
- Remove ArrayRef.h - Add SpanExtras.h for a couple of convenience functions
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "fmt/format.h"
|
||||
#include "wpi/SmallString.h"
|
||||
#include "wpi/SmallVector.h"
|
||||
#include "wpi/SpanExtras.h"
|
||||
#include "wpi/StringExtras.h"
|
||||
#include "wpi/fmt/raw_ostream.h"
|
||||
#include "wpi/raw_uv_ostream.h"
|
||||
@@ -83,10 +84,9 @@ void HttpServerConnection::BuildHeader(raw_ostream& os, int code,
|
||||
os << "\r\n"; // header ends with a blank line
|
||||
}
|
||||
|
||||
void HttpServerConnection::SendData(ArrayRef<uv::Buffer> bufs,
|
||||
void HttpServerConnection::SendData(span<const uv::Buffer> bufs,
|
||||
bool closeAfter) {
|
||||
m_stream.Write(bufs, [closeAfter, stream = &m_stream](
|
||||
MutableArrayRef<uv::Buffer> bufs, uv::Error) {
|
||||
m_stream.Write(bufs, [closeAfter, stream = &m_stream](auto bufs, uv::Error) {
|
||||
for (auto&& buf : bufs) {
|
||||
buf.Deallocate();
|
||||
}
|
||||
@@ -126,9 +126,9 @@ void HttpServerConnection::SendStaticResponse(
|
||||
bufs.emplace_back(content);
|
||||
|
||||
m_stream.Write(bufs, [closeAfter = !m_keepAlive, stream = &m_stream](
|
||||
MutableArrayRef<uv::Buffer> bufs, uv::Error) {
|
||||
auto bufs, uv::Error) {
|
||||
// don't deallocate the static content
|
||||
for (auto&& buf : bufs.drop_back()) {
|
||||
for (auto&& buf : wpi::drop_back(bufs)) {
|
||||
buf.Deallocate();
|
||||
}
|
||||
if (closeAfter) {
|
||||
|
||||
@@ -132,7 +132,7 @@ HttpPath::HttpPath(std::string_view path) {
|
||||
}
|
||||
|
||||
bool HttpPath::startswith(size_t start,
|
||||
ArrayRef<std::string_view> match) const {
|
||||
span<const std::string_view> match) const {
|
||||
if (m_pathEnds.size() < (start + match.size())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ static void CopyStream(uv::Stream& in, std::weak_ptr<uv::Stream> outWeak) {
|
||||
in.Close();
|
||||
return;
|
||||
}
|
||||
out->Write(buf2, [](auto bufs, uv::Error) {
|
||||
out->Write({buf2}, [](auto bufs, uv::Error) {
|
||||
for (auto buf : bufs) {
|
||||
buf.Deallocate();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ using namespace wpi;
|
||||
#endif
|
||||
|
||||
std::unique_ptr<NetworkStream> TCPConnector::connect_parallel(
|
||||
ArrayRef<std::pair<const char*, int>> servers, Logger& logger,
|
||||
span<const std::pair<const char*, int>> servers, Logger& logger,
|
||||
int timeout) {
|
||||
if (servers.empty()) {
|
||||
return nullptr;
|
||||
|
||||
@@ -133,7 +133,8 @@ void UDPClient::shutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
int UDPClient::send(ArrayRef<uint8_t> data, std::string_view server, int port) {
|
||||
int UDPClient::send(span<const uint8_t> data, std::string_view server,
|
||||
int port) {
|
||||
// server must be a resolvable IP address
|
||||
struct sockaddr_in addr;
|
||||
std::memset(&addr, 0, sizeof(addr));
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace {
|
||||
class WebSocketWriteReq : public uv::WriteReq {
|
||||
public:
|
||||
explicit WebSocketWriteReq(
|
||||
std::function<void(MutableArrayRef<uv::Buffer>, uv::Error)> callback) {
|
||||
std::function<void(span<uv::Buffer>, uv::Error)> callback) {
|
||||
finish.connect([=](uv::Error err) {
|
||||
MutableArrayRef<uv::Buffer> bufs{m_bufs};
|
||||
for (auto&& buf : bufs.slice(0, m_startUser)) {
|
||||
span<uv::Buffer> bufs{m_bufs};
|
||||
for (auto&& buf : bufs.subspan(0, m_startUser)) {
|
||||
buf.Deallocate();
|
||||
}
|
||||
callback(bufs.slice(m_startUser), err);
|
||||
callback(bufs.subspan(m_startUser), err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ WebSocket::~WebSocket() = default;
|
||||
|
||||
std::shared_ptr<WebSocket> WebSocket::CreateClient(
|
||||
uv::Stream& stream, std::string_view uri, std::string_view host,
|
||||
ArrayRef<std::string_view> protocols, const ClientOptions& options) {
|
||||
span<const std::string_view> protocols, const ClientOptions& options) {
|
||||
auto ws = std::make_shared<WebSocket>(stream, false, private_init{});
|
||||
stream.SetData(ws);
|
||||
ws->StartClient(uri, host, protocols, options);
|
||||
@@ -141,7 +141,7 @@ void WebSocket::Terminate(uint16_t code, std::string_view reason) {
|
||||
}
|
||||
|
||||
void WebSocket::StartClient(std::string_view uri, std::string_view host,
|
||||
ArrayRef<std::string_view> protocols,
|
||||
span<const std::string_view> protocols,
|
||||
const ClientOptions& options) {
|
||||
// Create client handshake data
|
||||
m_clientHandshake = std::make_unique<ClientHandshakeData>();
|
||||
@@ -317,7 +317,7 @@ void WebSocket::SendClose(uint16_t code, std::string_view reason) {
|
||||
raw_uv_ostream os{bufs, 4096};
|
||||
const uint8_t codeMsb[] = {static_cast<uint8_t>((code >> 8) & 0xff),
|
||||
static_cast<uint8_t>(code & 0xff)};
|
||||
os << ArrayRef<uint8_t>(codeMsb);
|
||||
os << span{codeMsb};
|
||||
os << reason;
|
||||
}
|
||||
Send(kFlagFin | kOpClose, bufs, [](auto bufs, uv::Error) {
|
||||
@@ -459,8 +459,7 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
|
||||
m_header[m_headerSize - 4], m_header[m_headerSize - 3],
|
||||
m_header[m_headerSize - 2], m_header[m_headerSize - 1]};
|
||||
int n = 0;
|
||||
for (uint8_t& ch :
|
||||
MutableArrayRef<uint8_t>{m_payload}.slice(m_frameStart)) {
|
||||
for (uint8_t& ch : span{m_payload}.subspan(m_frameStart)) {
|
||||
ch ^= key[n++];
|
||||
if (n >= 4) {
|
||||
n = 0;
|
||||
@@ -575,8 +574,8 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
|
||||
}
|
||||
|
||||
void WebSocket::Send(
|
||||
uint8_t opcode, ArrayRef<uv::Buffer> data,
|
||||
std::function<void(MutableArrayRef<uv::Buffer>, uv::Error)> callback) {
|
||||
uint8_t opcode, span<const uv::Buffer> data,
|
||||
std::function<void(span<uv::Buffer>, uv::Error)> callback) {
|
||||
// If we're not open, emit an error and don't send the data
|
||||
if (m_state != OPEN) {
|
||||
int err;
|
||||
@@ -607,7 +606,7 @@ void WebSocket::Send(
|
||||
os << static_cast<unsigned char>((m_server ? 0x00 : kFlagMasking) | 126);
|
||||
const uint8_t sizeMsb[] = {static_cast<uint8_t>((size >> 8) & 0xff),
|
||||
static_cast<uint8_t>(size & 0xff)};
|
||||
os << ArrayRef<uint8_t>(sizeMsb);
|
||||
os << span{sizeMsb};
|
||||
} else {
|
||||
os << static_cast<unsigned char>((m_server ? 0x00 : kFlagMasking) | 127);
|
||||
const uint8_t sizeMsb[] = {static_cast<uint8_t>((size >> 56) & 0xff),
|
||||
@@ -618,7 +617,7 @@ void WebSocket::Send(
|
||||
static_cast<uint8_t>((size >> 16) & 0xff),
|
||||
static_cast<uint8_t>((size >> 8) & 0xff),
|
||||
static_cast<uint8_t>(size & 0xff)};
|
||||
os << ArrayRef<uint8_t>(sizeMsb);
|
||||
os << span{sizeMsb};
|
||||
}
|
||||
|
||||
// clients need to mask the input data
|
||||
@@ -631,7 +630,7 @@ void WebSocket::Send(
|
||||
for (uint8_t& v : key) {
|
||||
v = dist(gen);
|
||||
}
|
||||
os << ArrayRef<uint8_t>{key, 4};
|
||||
os << span<const uint8_t>{key, 4};
|
||||
// copy and mask data
|
||||
int n = 0;
|
||||
for (auto&& buf : data) {
|
||||
@@ -645,8 +644,7 @@ void WebSocket::Send(
|
||||
req->m_startUser = req->m_bufs.size();
|
||||
req->m_bufs.append(data.begin(), data.end());
|
||||
// don't send the user bufs as we copied their data
|
||||
m_stream.Write(ArrayRef<uv::Buffer>{req->m_bufs}.slice(0, req->m_startUser),
|
||||
req);
|
||||
m_stream.Write(span{req->m_bufs}.subspan(0, req->m_startUser), req);
|
||||
} else {
|
||||
// servers can just send the buffers directly without masking
|
||||
req->m_startUser = req->m_bufs.size();
|
||||
|
||||
@@ -46,7 +46,7 @@ WebSocketServerHelper::WebSocketServerHelper(HttpParser& req) {
|
||||
}
|
||||
|
||||
std::pair<bool, std::string_view> WebSocketServerHelper::MatchProtocol(
|
||||
ArrayRef<std::string_view> protocols) {
|
||||
span<const std::string_view> protocols) {
|
||||
if (protocols.empty() && m_protocols.empty()) {
|
||||
return {true, {}};
|
||||
}
|
||||
@@ -61,7 +61,7 @@ std::pair<bool, std::string_view> WebSocketServerHelper::MatchProtocol(
|
||||
}
|
||||
|
||||
WebSocketServer::WebSocketServer(uv::Stream& stream,
|
||||
ArrayRef<std::string_view> protocols,
|
||||
span<const std::string_view> protocols,
|
||||
ServerOptions options, const private_init&)
|
||||
: m_stream{stream},
|
||||
m_helper{m_req},
|
||||
@@ -138,7 +138,7 @@ WebSocketServer::WebSocketServer(uv::Stream& stream,
|
||||
}
|
||||
|
||||
std::shared_ptr<WebSocketServer> WebSocketServer::Create(
|
||||
uv::Stream& stream, ArrayRef<std::string_view> protocols,
|
||||
uv::Stream& stream, span<const std::string_view> protocols,
|
||||
const ServerOptions& options) {
|
||||
auto server = std::make_shared<WebSocketServer>(stream, protocols, options,
|
||||
private_init{});
|
||||
|
||||
@@ -1384,7 +1384,7 @@ json json::from_cbor(raw_istream& is, const bool strict)
|
||||
return binary_reader(is).parse_cbor(strict);
|
||||
}
|
||||
|
||||
json json::from_cbor(ArrayRef<uint8_t> arr, const bool strict)
|
||||
json json::from_cbor(span<const uint8_t> arr, const bool strict)
|
||||
{
|
||||
raw_mem_istream is(arr);
|
||||
return from_cbor(is, strict);
|
||||
@@ -1395,7 +1395,7 @@ json json::from_msgpack(raw_istream& is, const bool strict)
|
||||
return binary_reader(is).parse_msgpack(strict);
|
||||
}
|
||||
|
||||
json json::from_msgpack(ArrayRef<uint8_t> arr, const bool strict)
|
||||
json json::from_msgpack(span<const uint8_t> arr, const bool strict)
|
||||
{
|
||||
raw_mem_istream is(arr);
|
||||
return from_msgpack(is, strict);
|
||||
@@ -1406,7 +1406,7 @@ json json::from_ubjson(raw_istream& is, const bool strict)
|
||||
return binary_reader(is).parse_ubjson(strict);
|
||||
}
|
||||
|
||||
json json::from_ubjson(ArrayRef<uint8_t> arr, const bool strict)
|
||||
json json::from_ubjson(span<const uint8_t> arr, const bool strict)
|
||||
{
|
||||
raw_mem_istream is(arr);
|
||||
return from_ubjson(is, strict);
|
||||
|
||||
@@ -813,7 +813,7 @@ void json::binary_writer::write_number(const NumberType n)
|
||||
std::reverse(vec.begin(), vec.end());
|
||||
}
|
||||
|
||||
o << ArrayRef<uint8_t>(vec.data(), sizeof(NumberType));
|
||||
o << span{vec.data(), sizeof(NumberType)};
|
||||
}
|
||||
|
||||
template<typename NumberType, typename std::enable_if<
|
||||
@@ -1004,7 +1004,7 @@ std::vector<uint8_t> json::to_cbor(const json& j)
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_cbor(const json& j, std::vector<uint8_t>& buf)
|
||||
span<uint8_t> json::to_cbor(const json& j, std::vector<uint8_t>& buf)
|
||||
{
|
||||
buf.clear();
|
||||
raw_uvector_ostream os(buf);
|
||||
@@ -1012,7 +1012,7 @@ ArrayRef<uint8_t> json::to_cbor(const json& j, std::vector<uint8_t>& buf)
|
||||
return os.array();
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_cbor(const json& j, SmallVectorImpl<uint8_t>& buf)
|
||||
span<uint8_t> json::to_cbor(const json& j, SmallVectorImpl<uint8_t>& buf)
|
||||
{
|
||||
buf.clear();
|
||||
raw_usvector_ostream os(buf);
|
||||
@@ -1033,7 +1033,7 @@ std::vector<uint8_t> json::to_msgpack(const json& j)
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_msgpack(const json& j, std::vector<uint8_t>& buf)
|
||||
span<uint8_t> json::to_msgpack(const json& j, std::vector<uint8_t>& buf)
|
||||
{
|
||||
buf.clear();
|
||||
raw_uvector_ostream os(buf);
|
||||
@@ -1041,7 +1041,7 @@ ArrayRef<uint8_t> json::to_msgpack(const json& j, std::vector<uint8_t>& buf)
|
||||
return os.array();
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_msgpack(const json& j, SmallVectorImpl<uint8_t>& buf)
|
||||
span<uint8_t> json::to_msgpack(const json& j, SmallVectorImpl<uint8_t>& buf)
|
||||
{
|
||||
buf.clear();
|
||||
raw_usvector_ostream os(buf);
|
||||
@@ -1064,8 +1064,8 @@ std::vector<uint8_t> json::to_ubjson(const json& j,
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_ubjson(const json& j, std::vector<uint8_t>& buf,
|
||||
const bool use_size, const bool use_type)
|
||||
span<uint8_t> json::to_ubjson(const json& j, std::vector<uint8_t>& buf,
|
||||
const bool use_size, const bool use_type)
|
||||
{
|
||||
buf.clear();
|
||||
raw_uvector_ostream os(buf);
|
||||
@@ -1073,8 +1073,8 @@ ArrayRef<uint8_t> json::to_ubjson(const json& j, std::vector<uint8_t>& buf,
|
||||
return os.array();
|
||||
}
|
||||
|
||||
ArrayRef<uint8_t> json::to_ubjson(const json& j, SmallVectorImpl<uint8_t>& buf,
|
||||
const bool use_size, const bool use_type)
|
||||
span<uint8_t> json::to_ubjson(const json& j, SmallVectorImpl<uint8_t>& buf,
|
||||
const bool use_size, const bool use_type)
|
||||
{
|
||||
buf.clear();
|
||||
raw_usvector_ostream os(buf);
|
||||
|
||||
@@ -1921,11 +1921,11 @@ json json::parse(std::string_view s,
|
||||
const parser_callback_t cb,
|
||||
const bool allow_exceptions)
|
||||
{
|
||||
raw_mem_istream is(makeArrayRef(s.data(), s.size()));
|
||||
raw_mem_istream is(span<const char>(s.data(), s.size()));
|
||||
return parse(is, cb, allow_exceptions);
|
||||
}
|
||||
|
||||
json json::parse(ArrayRef<uint8_t> arr,
|
||||
json json::parse(span<const uint8_t> arr,
|
||||
const parser_callback_t cb,
|
||||
const bool allow_exceptions)
|
||||
{
|
||||
@@ -1944,11 +1944,11 @@ json json::parse(raw_istream& i,
|
||||
|
||||
bool json::accept(std::string_view s)
|
||||
{
|
||||
raw_mem_istream is(makeArrayRef(s.data(), s.size()));
|
||||
raw_mem_istream is(span<const char>(s.data(), s.size()));
|
||||
return parser(is).accept(true);
|
||||
}
|
||||
|
||||
bool json::accept(ArrayRef<uint8_t> arr)
|
||||
bool json::accept(span<const uint8_t> arr)
|
||||
{
|
||||
raw_mem_istream is(arr);
|
||||
return parser(is).accept(true);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "wpi/ConvertUTF.h"
|
||||
#include "wpi/SmallVector.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -28,13 +29,13 @@ bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasUTF16ByteOrderMark(ArrayRef<char> S) {
|
||||
bool hasUTF16ByteOrderMark(span<const char> S) {
|
||||
return (S.size() >= 2 &&
|
||||
((S[0] == '\xff' && S[1] == '\xfe') ||
|
||||
(S[0] == '\xfe' && S[1] == '\xff')));
|
||||
}
|
||||
|
||||
bool convertUTF16ToUTF8String(ArrayRef<UTF16> SrcUTF16,
|
||||
bool convertUTF16ToUTF8String(span<const UTF16> SrcUTF16,
|
||||
SmallVectorImpl<char> &DstUTF8) {
|
||||
assert(DstUTF8.empty());
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "wpi/SmallPtrSet.h"
|
||||
#include "wpi/DenseMapInfo.h"
|
||||
#include "wpi/MathExtras.h"
|
||||
#include "wpi/MemAlloc.h"
|
||||
#include "wpi/ErrorHandling.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
@@ -217,7 +217,7 @@ SHA1::SHA1() {
|
||||
}
|
||||
|
||||
void SHA1::Update(std::string_view s) {
|
||||
raw_mem_istream is(makeArrayRef(s.data(), s.size()));
|
||||
raw_mem_istream is(span<const char>(s.data(), s.size()));
|
||||
Update(is);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace wpi::uv {
|
||||
|
||||
std::shared_ptr<Process> Process::SpawnArray(Loop& loop, std::string_view file,
|
||||
ArrayRef<Option> options) {
|
||||
span<const Option> options) {
|
||||
// convert Option array to libuv structure
|
||||
uv_process_options_t coptions;
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ using namespace wpi::uv;
|
||||
namespace {
|
||||
class CallbackWriteReq : public WriteReq {
|
||||
public:
|
||||
CallbackWriteReq(ArrayRef<Buffer> bufs,
|
||||
std::function<void(MutableArrayRef<Buffer>, Error)> callback)
|
||||
CallbackWriteReq(span<const Buffer> bufs,
|
||||
std::function<void(span<Buffer>, Error)> callback)
|
||||
: m_bufs{bufs.begin(), bufs.end()} {
|
||||
finish.connect([=](Error err) { callback(m_bufs, err); });
|
||||
}
|
||||
@@ -76,7 +76,7 @@ void Stream::StartRead() {
|
||||
});
|
||||
}
|
||||
|
||||
void Stream::Write(ArrayRef<Buffer> bufs,
|
||||
void Stream::Write(span<const Buffer> bufs,
|
||||
const std::shared_ptr<WriteReq>& req) {
|
||||
if (Invoke(&uv_write, req->GetRaw(), GetRawStream(), bufs.data(), bufs.size(),
|
||||
[](uv_write_t* r, int status) {
|
||||
@@ -91,13 +91,12 @@ void Stream::Write(ArrayRef<Buffer> bufs,
|
||||
}
|
||||
}
|
||||
|
||||
void Stream::Write(
|
||||
ArrayRef<Buffer> bufs,
|
||||
std::function<void(MutableArrayRef<Buffer>, Error)> callback) {
|
||||
void Stream::Write(span<const Buffer> bufs,
|
||||
std::function<void(span<Buffer>, Error)> callback) {
|
||||
Write(bufs, std::make_shared<CallbackWriteReq>(bufs, callback));
|
||||
}
|
||||
|
||||
int Stream::TryWrite(ArrayRef<Buffer> bufs) {
|
||||
int Stream::TryWrite(span<const Buffer> bufs) {
|
||||
int val = uv_try_write(GetRawStream(), bufs.data(), bufs.size());
|
||||
if (val < 0) {
|
||||
this->ReportError(val);
|
||||
|
||||
@@ -17,9 +17,8 @@ using namespace wpi::uv;
|
||||
|
||||
class CallbackUdpSendReq : public UdpSendReq {
|
||||
public:
|
||||
CallbackUdpSendReq(
|
||||
ArrayRef<Buffer> bufs,
|
||||
std::function<void(MutableArrayRef<Buffer>, Error)> callback)
|
||||
CallbackUdpSendReq(span<const Buffer> bufs,
|
||||
std::function<void(span<Buffer>, Error)> callback)
|
||||
: m_bufs{bufs.begin(), bufs.end()} {
|
||||
complete.connect([=](Error err) { callback(m_bufs, err); });
|
||||
}
|
||||
@@ -121,7 +120,7 @@ void Udp::SetMulticastInterface(std::string_view interfaceAddr) {
|
||||
Invoke(&uv_udp_set_multicast_interface, GetRaw(), interfaceAddrBuf.c_str());
|
||||
}
|
||||
|
||||
void Udp::Send(const sockaddr& addr, ArrayRef<Buffer> bufs,
|
||||
void Udp::Send(const sockaddr& addr, span<const Buffer> bufs,
|
||||
const std::shared_ptr<UdpSendReq>& req) {
|
||||
if (Invoke(&uv_udp_send, req->GetRaw(), GetRaw(), bufs.data(), bufs.size(),
|
||||
&addr, [](uv_udp_send_t* r, int status) {
|
||||
@@ -136,12 +135,13 @@ void Udp::Send(const sockaddr& addr, ArrayRef<Buffer> bufs,
|
||||
}
|
||||
}
|
||||
|
||||
void Udp::Send(const sockaddr& addr, ArrayRef<Buffer> bufs,
|
||||
std::function<void(MutableArrayRef<Buffer>, Error)> callback) {
|
||||
void Udp::Send(const sockaddr& addr, span<const Buffer> bufs,
|
||||
std::function<void(span<Buffer>, Error)> callback) {
|
||||
Send(addr, bufs, std::make_shared<CallbackUdpSendReq>(bufs, callback));
|
||||
}
|
||||
|
||||
void Udp::Send(ArrayRef<Buffer> bufs, const std::shared_ptr<UdpSendReq>& req) {
|
||||
void Udp::Send(span<const Buffer> bufs,
|
||||
const std::shared_ptr<UdpSendReq>& req) {
|
||||
if (Invoke(&uv_udp_send, req->GetRaw(), GetRaw(), bufs.data(), bufs.size(),
|
||||
nullptr, [](uv_udp_send_t* r, int status) {
|
||||
auto& h = *static_cast<UdpSendReq*>(r->data);
|
||||
@@ -155,8 +155,8 @@ void Udp::Send(ArrayRef<Buffer> bufs, const std::shared_ptr<UdpSendReq>& req) {
|
||||
}
|
||||
}
|
||||
|
||||
void Udp::Send(ArrayRef<Buffer> bufs,
|
||||
std::function<void(MutableArrayRef<Buffer>, Error)> callback) {
|
||||
void Udp::Send(span<const Buffer> bufs,
|
||||
std::function<void(span<Buffer>, Error)> callback) {
|
||||
Send(bufs, std::make_shared<CallbackUdpSendReq>(bufs, callback));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user