18 #include "hazelcast/client/proxy/RingbufferImpl.h"
20 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
22 #pragma warning(disable : 4251)
65 class HAZELCAST_API
ringbuffer :
public proxy::RingbufferImpl
67 friend class spi::ProxyManager;
93 boost::future<int64_t>
add(
const E& item)
95 return add_data(to_data(item));
137 boost::future<boost::optional<E>>
read_one(int64_t sequence)
139 return to_object<E>(read_one_data(sequence));
173 boost::future<int64_t>
add(
const E& item,
174 rb::overflow_policy overflow_policy)
176 return addData(to_data(item), overflow_policy);
198 boost::future<int64_t>
add_all(
const std::vector<E>& items,
199 rb::overflow_policy overflow_policy)
201 return add_all_data(to_data_collection(items), overflow_policy);
243 template<
typename IFUNCTION>
245 int64_t start_sequence,
248 const IFUNCTION* filter =
nullptr)
250 auto filter_data = to_data<IFUNCTION>(filter);
251 return read_many_data(
252 start_sequence, min_count, max_count, &filter_data)
253 .then(boost::launch::sync,
254 [=](boost::future<protocol::ClientMessage> f) {
255 return get_result_set(std::move(f));
262 auto* initial_frame =
263 reinterpret_cast<protocol::ClientMessage::frame_header_type*
>(
264 msg.rd_ptr(protocol::ClientMessage::RESPONSE_HEADER_LEN));
265 auto read_count = msg.get<int32_t>();
266 auto next_seq = msg.get<int64_t>();
267 msg.rd_ptr(
static_cast<int32_t
>(initial_frame->frame_len) -
268 protocol::ClientMessage::RESPONSE_HEADER_LEN -
269 protocol::ClientMessage::INT32_SIZE -
270 protocol::ClientMessage::INT64_SIZE);
272 auto datas = msg.get<std::vector<serialization::pimpl::data>>();
273 auto item_seqs = msg.get_nullable<std::vector<int64_t>>();
276 get_serialization_service(),
281 boost::future<rb::read_result_set> read_many(int64_t start_sequence,
285 return read_many_data(start_sequence, min_count, max_count,
nullptr)
286 .then(boost::launch::sync,
287 [=](boost::future<protocol::ClientMessage> f) {
288 return get_result_set(std::move(f));
293 ringbuffer(
const std::string& object_name, spi::ClientContext* context)
294 : RingbufferImpl(object_name, context)
300 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
A Ringbuffer is a data-structure where the content is stored in a ring like structure.
boost::future< int64_t > add_all(const std::vector< E > &items, rb::overflow_policy overflow_policy)
Adds all the items of a collection to the tail of the Ringbuffer.
boost::future< rb::read_result_set > read_many(int64_t start_sequence, int32_t min_count, int32_t max_count, const IFUNCTION *filter=nullptr)
Reads a batch of items from the Ringbuffer.
boost::future< int64_t > add(const E &item, rb::overflow_policy overflow_policy)
Asynchronously writes an item with a configurable {}.
boost::future< int64_t > add(const E &item)
Adds an item to the tail of the Ringbuffer.
boost::future< boost::optional< E > > read_one(int64_t sequence)
Reads one item from the Ringbuffer.