8 #ifndef WPIUTIL_WPI_UV_STREAM_H_
9 #define WPIUTIL_WPI_UV_STREAM_H_
16 #include "wpi/ArrayRef.h"
17 #include "wpi/Signal.h"
18 #include "wpi/uv/Buffer.h"
19 #include "wpi/uv/Handle.h"
20 #include "wpi/uv/Request.h"
34 Stream& GetStream()
const {
51 Stream& GetStream()
const {
70 std::shared_ptr<Stream> shared_from_this() {
71 return std::static_pointer_cast<
Stream>(Handle::shared_from_this());
74 std::shared_ptr<const Stream> shared_from_this()
const {
75 return std::static_pointer_cast<
const Stream>(Handle::shared_from_this());
85 void Shutdown(
const std::shared_ptr<ShutdownReq>& req);
95 void Shutdown(std::function<
void()> callback =
nullptr);
189 return uv_stream_set_blocking(
GetRawStream(), enable) == 0;
224 template <
typename T,
typename U>
227 std::shared_ptr<T> shared_from_this() {
228 return std::static_pointer_cast<T>(Handle::shared_from_this());
231 std::shared_ptr<const T> shared_from_this()
const {
232 return std::static_pointer_cast<
const T>(Handle::shared_from_this());
251 #endif // WPIUTIL_WPI_UV_STREAM_H_
void Write(ArrayRef< Buffer > bufs, const std::shared_ptr< WriteReq > &req)
Write data to the stream.
int TryWrite(ArrayRef< Buffer > bufs)
Queue a write request if it can be completed immediately.
void StopRead()
Stop reading data from the stream.
Definition: Stream.h:113
void StartRead()
Start reading data from an incoming stream.
sig::Signal complete
Shutdown completed signal.
Definition: Stream.h:41
size_t GetWriteQueueSize() const noexcept
Gets the amount of queued bytes waiting to be sent.
Definition: Stream.h:196
sig::Signal end
Signal generated when no more read data is available.
Definition: Stream.h:217
sig::Signal< Error > finish
Write completed signal.
Definition: Stream.h:59
Write request.
Definition: Stream.h:47
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
namespace to hold default to_json function
Definition: SmallString.h:21
Stream handle.
Definition: Stream.h:68
uv_shutdown_t * GetRaw() noexcept
Get the underlying request data structure.
Definition: Request.h:149
sig::Signal< Buffer &, size_t > data
Signal generated when data was read on a stream.
Definition: Stream.h:212
U * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Stream.h:240
bool SetBlocking(bool enable) noexcept
Enable or disable blocking mode for a stream.
Definition: Stream.h:188
uv_stream_t * GetRawStream() const noexcept
Get the underlying stream data structure.
Definition: Stream.h:205
Shutdown request.
Definition: Stream.h:30
bool IsWritable() const noexcept
Checks if the stream is writable.
Definition: Stream.h:173
Error code.
Definition: Error.h:19
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Request.
Definition: Request.h:134
Handle.
Definition: Handle.h:32
uv_handle_t * GetRawHandle() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:153
void Shutdown(const std::shared_ptr< ShutdownReq > &req)
Shutdown the outgoing (write) side of a duplex stream.
bool IsReadable() const noexcept
Check if the stream is readable.
Definition: Stream.h:165
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:291