FEATURE: expose write_queue_size (#109)

more functions exposed by stream and udp
This commit is contained in:
bmagistro 2018-02-05 16:35:34 -05:00 committed by Michele Caini
parent f3da3a8476
commit 7abf541dc5
2 changed files with 27 additions and 0 deletions

View File

@ -445,6 +445,14 @@ public:
bool blocking(bool enable = false) {
return (0 == uv_stream_set_blocking(this->template get<uv_stream_t>(), enable));
}
/**
* @brief Gets the amount of queued bytes waiting to be sent.
* @return Amount of queued bytes waiting to be sent.
*/
size_t writeQueueSize() const noexcept {
return uv_stream_get_write_queue_size(this->template get<uv_stream_t>());
}
};

View File

@ -593,6 +593,25 @@ public:
invoke(&uv_udp_recv_stop, get());
}
/**
* @brief Gets the number of bytes queued for sending.
*
* It strictly shows how much information is currently queued.
*
* @return Number of bytes queued for sending.
*/
size_t sendQueueSize() const noexcept {
return uv_udp_get_send_queue_size(get());
}
/**
* @brief Number of send requests currently in the queue awaiting to be processed.
* @return Number of send requests currently in the queue.
*/
size_t sendQueueCount() const noexcept {
return uv_udp_get_send_queue_count(get());
}
private:
enum { DEFAULT, FLAGS } tag{DEFAULT};
unsigned int flags{};