0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 08:23:56 +01:00

ircd::net: Cleanup interface arguments w/ common alias.

This commit is contained in:
Jason Volk 2020-10-19 17:36:38 -07:00
parent 33e54f1ccb
commit 8b4fdf49c4
2 changed files with 16 additions and 12 deletions

View file

@ -13,24 +13,26 @@
namespace ircd::net
{
using mutable_buffers = vector_view<const mutable_buffer>;
// Non-blocking; read into buffers in a single syscall
size_t read_one(socket &, const vector_view<const mutable_buffer> &);
size_t read_one(socket &, const mutable_buffers &);
size_t read_one(socket &, const mutable_buffer &);
// Non-blocking; read as much as possible into buffers
size_t read_any(socket &, const vector_view<const mutable_buffer> &);
size_t read_any(socket &, const mutable_buffers &);
size_t read_any(socket &, const mutable_buffer &);
// Yields until something is read into buffers.
size_t read_few(socket &, const vector_view<const mutable_buffer> &);
size_t read_few(socket &, const mutable_buffers &);
size_t read_few(socket &, const mutable_buffer &);
// Yields until buffers are entirely full.
size_t read_all(socket &, const vector_view<const mutable_buffer> &);
size_t read_all(socket &, const mutable_buffers &);
size_t read_all(socket &, const mutable_buffer &);
// Alias to read_few();
size_t read(socket &, const vector_view<const mutable_buffer> &);
size_t read(socket &, const mutable_buffers &);
size_t read(socket &, const mutable_buffer &);
// Non-blocking; discard up to len, but less may be discarded.
@ -51,7 +53,7 @@ ircd::net::read(socket &socket,
/// Alias to read_few();
inline size_t
ircd::net::read(socket &socket,
const vector_view<const mutable_buffer> &buffers)
const mutable_buffers &buffers)
{
return read_few(socket, buffers);
}

View file

@ -13,28 +13,30 @@
namespace ircd::net
{
using const_buffers = vector_view<const const_buffer>;
// Non-blocking; writes at most one system-determined amount of
// bytes or less with at most a single syscall.
size_t write_one(socket &, const vector_view<const const_buffer> &);
size_t write_one(socket &, const const_buffers &);
size_t write_one(socket &, const const_buffer &);
// Non-blocking; writes as much as possible until the socket buffer
// is full. This composes multiple write_one()'s.
size_t write_any(socket &, const vector_view<const const_buffer> &);
size_t write_any(socket &, const const_buffers &);
size_t write_any(socket &, const const_buffer &);
// Yields your ircd::ctx until at least some bytes have been written;
// advise one uses a timeout when calling.
size_t write_few(socket &, const vector_view<const const_buffer> &);
size_t write_few(socket &, const const_buffers &);
size_t write_few(socket &, const const_buffer &);
// Yields your ircd::ctx until all bytes have been written;
// advise one uses a timeout in conjunction to prevent DoS.
size_t write_all(socket &, const vector_view<const const_buffer> &);
size_t write_all(socket &, const const_buffers &);
size_t write_all(socket &, const const_buffer &);
// Alias to write_all();
size_t write(socket &, const vector_view<const const_buffer> &);
size_t write(socket &, const const_buffers &);
size_t write(socket &, const const_buffer &);
// Toggles nodelay to force a transmission.
@ -52,7 +54,7 @@ ircd::net::write(socket &socket,
/// Alias to write_all();
inline size_t
ircd::net::write(socket &socket,
const vector_view<const const_buffer> &buffers)
const const_buffers &buffers)
{
return write_all(socket, buffers);
}