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

Event triggered when all buffered data has been successfully written and sent to an output stream. More...

#include <eos.h>

Detailed Description

Event triggered when all buffered data has been successfully written and sent to an output stream.

This event is passed to the derived class's on(qb::io::async::event::eos&&) method when the output buffer for an I/O object (e.g., TCP socket) becomes empty after a write operation. It signifies that all data previously queued for sending via publish() or operator<< has been flushed to the underlying transport.

This is often used to signal completion of a data transfer or to manage flow control (e.g., stop listening for write readiness on the socket until more data is available).

Usage Example:

class MyOutputHandler : public qb::io::async::output<MyOutputHandler> { // Or similar base
public:
// ... other methods ...
void sendLargeData(const char* data, size_t size) {
this->publish(data, size); // Add data to output buffer
// The async::output base will handle writing and trigger eos when done.
}
void on(qb::io::async::event::eos &&) {
LOG_INFO("All pending data has been sent.");
// Optionally, close the connection if this was the last piece of data,
// or notify another component about the completion.
// if (isLastChunk()) {
// this->disconnect();
// }
}
};
CRTP base class for managing asynchronous output operations.
Definition io.h:755
auto & publish(_Args &&...args) noexcept
Publishes data to the output buffer and ensures write readiness.
Definition io.h:815
#define LOG_INFO(X)
Info-level log macro (no-op if QB_STDOUT_LOG is not defined)
Definition io.h:229