qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::io::async::event::pending_write Struct Reference

Event triggered when unsent data remains in the output buffer after a write operation. More...

#include <pending_write.h>

Public Attributes

std::size_t bytes
 Number of unsent bytes remaining in the write buffer after a partial write operation.

Detailed Description

Event triggered when unsent data remains in the output buffer after a write operation.

This event is passed to the derived class's on(qb::io::async::event::pending_write&&) method by some asynchronous output components (like qb::io::async::output or qb::io::async::io) if a write() operation to the underlying transport did not send all the data currently in the output buffer (e.g., because the socket's send buffer was full).

The bytes member indicates how much data is still pending. The I/O component will typically continue to listen for write readiness and attempt to send the remaining data. This event is useful for monitoring buffer utilization, implementing flow control (e.g., pausing data production if the buffer grows too large), or tracking the progress of large data transfers.

Usage Example:

class MyDataSender : public qb::io::async::output<MyDataSender> {
public:
// ... other methods ...
void on(qb::io::async::event::pending_write &&event) {
LOG_DEBUG("Pending write data: " << event.bytes << " bytes still in output buffer.");
if (event.bytes > HIGH_WATER_MARK) {
// pauseProducingData(); // Example of flow control
}
}
void on(qb::io::async::event::eos &&) { // End Of Stream
LOG_DEBUG("All data sent, output buffer empty.");
// resumeProducingData();
}
};
CRTP base class for managing asynchronous output operations.
Definition io.h:755
#define LOG_DEBUG(X)
Debug-level log macro (no-op if QB_STDOUT_LOG is not defined)
Definition io.h:215