Allow access to the user-supplied delivery callback.

This commit is contained in:
accelerated
2018-05-15 11:18:22 -04:00
parent 6144330835
commit 556f15a43f

View File

@@ -178,6 +178,13 @@ public:
*/
void clear();
/**
* \brief Get the number of messages in the buffer
*
* \return The number of messages
*/
size_t get_buffer_size() const;
/**
* \brief Sets the maximum amount of messages to be enqueued in the buffer.
*
@@ -400,6 +407,11 @@ void BufferedProducer<BufferType>::clear() {
std::swap(tmp, messages_);
}
template <typename BufferType>
size_t BufferedProducer<BufferType>::get_buffer_size() const {
return messages_.size();
}
template <typename BufferType>
void BufferedProducer<BufferType>::set_max_buffer_size(ssize_t max_buffer_size) {
if (max_buffer_size < -1) {
@@ -413,11 +425,6 @@ ssize_t BufferedProducer<BufferType>::get_max_buffer_size() const {
return max_buffer_size_;
}
template <typename BufferType>
size_t BufferedProducer<BufferType>::get_buffer_size() const {
return messages_.size();
}
template <typename BufferType>
template <typename BuilderType>
void BufferedProducer<BufferType>::do_add_message(BuilderType&& builder,
@@ -508,6 +515,7 @@ void BufferedProducer<BufferType>::produce_message(const MessageType& message) {
template <typename BufferType>
Configuration BufferedProducer<BufferType>::prepare_configuration(Configuration config) {
using std::placeholders::_2;
delivery_report_callback_ = config.get_delivery_report_callback();
auto callback = std::bind(&BufferedProducer<BufferType>::on_delivery_report, this, _2);
config.set_delivery_report_callback(std::move(callback));
return config;