18 #include "hazelcast/client/item_listener.h"
19 #include "hazelcast/client/proxy/IQueueImpl.h"
20 #include "hazelcast/client/impl/ItemEventHandler.h"
21 #include "hazelcast/client/protocol/codec/codecs.h"
29 class iqueue :
public proxy::IQueueImpl
31 friend class spi::ProxyManager;
34 static constexpr
const char* SERVICE_NAME =
"hz:impl:queueService";
55 impl::item_event_handler<protocol::codec::queue_addlistener_handler>>
56 itemEventHandler(
new impl::item_event_handler<
57 protocol::codec::queue_addlistener_handler>(
59 get_context().get_client_cluster_service(),
60 get_context().get_serialization_service(),
64 return proxy::IQueueImpl::add_item_listener(std::move(itemEventHandler),
76 boost::future<bool>
offer(
const E& element)
78 return offer(element, std::chrono::milliseconds(0));
86 boost::future<void>
put(
const E& element)
88 return proxy::IQueueImpl::put(to_data(element));
101 boost::future<bool>
offer(
const E& element,
102 std::chrono::milliseconds timeout)
104 return proxy::IQueueImpl::offer(to_data(element), timeout);
113 boost::future<boost::optional<E>>
take()
115 return to_object<E>(proxy::IQueueImpl::take_data());
125 boost::future<boost::optional<E>>
poll(std::chrono::milliseconds timeout)
127 return to_object<E>(proxy::IQueueImpl::poll_data(timeout));
136 boost::future<bool>
remove(
const E& element)
138 return proxy::IQueueImpl::remove(to_data(element));
149 return proxy::IQueueImpl::contains(to_data(element));
159 boost::future<size_t>
drain_to(std::vector<E>& elements)
161 return to_object_drain(proxy::IQueueImpl::drain_to_data(), elements);
172 boost::future<size_t>
drain_to(std::vector<E>& elements,
175 return to_object_drain(proxy::IQueueImpl::drain_to_data(max_elements),
186 boost::future<boost::optional<E>>
poll()
188 return poll<E>(std::chrono::milliseconds(0));
198 boost::future<boost::optional<E>>
peek()
200 return to_object<E>(proxy::IQueueImpl::peek_data());
210 return to_object_vector<E>(proxy::IQueueImpl::to_array_data());
221 return proxy::IQueueImpl::contains_all_data(
222 to_data_collection(elements));
231 boost::future<bool>
add_all(
const std::vector<E>& elements)
233 return proxy::IQueueImpl::add_all_data(to_data_collection(elements));
242 boost::future<bool>
remove_all(
const std::vector<E>& elements)
244 return proxy::IQueueImpl::remove_all_data(to_data_collection(elements));
255 boost::future<bool>
retain_all(
const std::vector<E>& elements)
257 return proxy::IQueueImpl::retain_all_data(to_data_collection(elements));
261 iqueue(
const std::string& instance_name, spi::ClientContext* context)
262 : proxy::IQueueImpl(instance_name, context)
Concurrent, blocking, distributed, observable, client queue.
boost::future< boost::optional< E > > poll(std::chrono::milliseconds timeout)
boost::future< bool > remove(const E &element)
boost::future< bool > contains(const E &element)
boost::future< boost::optional< E > > peek()
Returns immediately without waiting.
boost::future< bool > add_all(const std::vector< E > &elements)
boost::future< size_t > drain_to(std::vector< E > &elements, size_t max_elements)
Note that elements will be pushed_back to vector.
boost::future< bool > offer(const E &element, std::chrono::milliseconds timeout)
Inserts the specified element into this queue.
boost::future< boost::optional< E > > poll()
Returns immediately without waiting.
boost::future< bool > remove_all(const std::vector< E > &elements)
boost::future< bool > contains_all(const std::vector< E > &elements)
boost::future< std::vector< E > > to_array()
boost::future< void > put(const E &element)
Puts the element into queue.
boost::future< bool > offer(const E &element)
Inserts the specified element into this queue.
boost::future< boost::uuids::uuid > add_item_listener(item_listener &&listener, bool include_value)
Adds an item listener for this collection.
boost::future< bool > retain_all(const std::vector< E > &elements)
Removes the elements from this queue that are not available in given "elements" vector.
boost::future< size_t > drain_to(std::vector< E > &elements)
Note that elements will be pushed_back to vector.
boost::future< boost::optional< E > > take()
Item listener for IQueue, ISet and IList.