-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsocket_buffered_impl.h
41 lines (31 loc) · 1.09 KB
/
socket_buffered_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef SOCKPUPPET_SOCKET_BUFFERED_IMPL_H
#define SOCKPUPPET_SOCKET_BUFFERED_IMPL_H
#include "socket_impl.h" // for SocketImpl
#include "sockpuppet/address.h" // for Address
#include "sockpuppet/socket_buffered.h" // for BufferPool
#include <cstddef> // for size_t
#include <memory> // for std::unique_ptr
#include <optional> // for std::optional
#include <utility> // for std::pair
namespace sockpuppet {
struct SocketBufferedImpl
{
std::unique_ptr<SocketImpl> sock;
size_t rxBufSize;
std::unique_ptr<BufferPool> pool;
SocketBufferedImpl(std::unique_ptr<SocketImpl> &&sock,
size_t rxBufCount,
size_t rxBufSize);
SocketBufferedImpl(SocketBufferedImpl const &) = delete;
SocketBufferedImpl(SocketBufferedImpl &&other) noexcept;
~SocketBufferedImpl();
BufferPtr GetBuffer();
std::optional<BufferPtr> Receive(Duration timeout);
BufferPtr Receive();
std::optional<std::pair<BufferPtr, Address>>
ReceiveFrom(Duration timeout);
std::pair<BufferPtr, Address>
ReceiveFrom();
};
} // namespace sockpuppet
#endif // SOCKPUPPET_SOCKET_BUFFERED_IMPL_H