class producer - 5cript/attender GitHub Wiki
This represents an object that produces sendable streamable data.
| Members | Descriptions |
|---|---|
public virtual ~producer() |
|
public void set_finish_callback(std::function< void(boost::system::error_code)> const & on_finish) |
|
public bool has_consumer_attached() const |
Returns false when the connection is not consuming. |
public bool wait_for_consumer(std::chrono::milliseconds timeout) const |
Waits for setup on the connection. |
public std::string encoding() const |
Returns the encoding the producer provides. |
public std::size_t available() const |
The amount of available data in the buffer. |
public char const * data() const |
A pointer to the begin of the buffer. |
public void buffer_locked_do(std::function< void()> const &) const |
Everything within the supplied function is guarded by a mutex that also guards other buffer accesses. |
public bool complete() const |
Returns whether the data production has ended. |
public virtual void has_consumed(std::size_t size) |
The base class calls this function to signal that some data has been consumed. |
public void on_error(boost::system::error_code) |
This function is called when the write function returns an error. |
public void start_production() |
The server calls this function when a consumer is attached. |
public virtual void end_production(boost::system::error_code) |
The server calls this function for teardown purposes. |
public void set_on_produce_cb(std::function< void(std::string const &err, bool)> cb) |
Set a callback for when new data is available. |
protected std::atomic_bool consuming_ |
|
protected void produced_data() const |
Call this if the amount of available data increased. |
protected void production_failure(std::string const & fail) |
Call this if the production somehow failed in a way that is unrecoverable and interupts the stream. |
Returns false when the connection is not consuming.
Waits for setup on the connection.
Returns: returns false on timeout
Returns the encoding the producer provides.
The amount of available data in the buffer.
A pointer to the begin of the buffer.
Everything within the supplied function is guarded by a mutex that also guards other buffer accesses.
Returns whether the data production has ended.
The base class calls this function to signal that some data has been consumed.
Always call the base class function at the end of your implementation.
This function is called when the write function returns an error.
Use this to stop any production.
The server calls this function when a consumer is attached.
The server calls this function for teardown purposes.
This usually means that the connection is dead.
Call base class function if you override
Set a callback for when new data is available.
Call this if the amount of available data increased.
Call this if the production somehow failed in a way that is unrecoverable and interupts the stream.