16 #ifndef HAZELCAST_IQUEUE 17 #define HAZELCAST_IQUEUE 21 #include "hazelcast/client/proxy/IQueueImpl.h" 22 #include "hazelcast/client/ItemListener.h" 23 #include "hazelcast/client/impl/ItemEventHandler.h" 24 #include "hazelcast/client/protocol/codec/QueueAddListenerCodec.h" 30 class RawPointerQueue;
39 class IQueue :
public proxy::IQueueImpl {
40 friend class impl::HazelcastClientInstanceImpl;
59 spi::ClientClusterService &cs = getContext().getClientClusterService();
60 serialization::pimpl::SerializationService& ss = getContext().getSerializationService();
61 impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler> *itemEventHandler =
62 new impl::ItemEventHandler<E, protocol::codec::QueueAddListenerCodec::AbstractEventHandler>(getName(), cs, ss, listener, includeValue);
63 return proxy::IQueueImpl::addItemListener(itemEventHandler, includeValue);
75 return proxy::IQueueImpl::removeItemListener(registrationId);
87 return offer(element, 0);
94 void put(
const E& element) {
95 proxy::IQueueImpl::put(toData(element));
107 bool offer(
const E& element,
long timeoutInMillis) {
108 return proxy::IQueueImpl::offer(toData(element), timeoutInMillis);
124 boost::shared_ptr<E>
poll(
long timeoutInMillis) {
125 return boost::shared_ptr<E>(boost::shared_ptr<E>(toObject<E>(
126 proxy::IQueueImpl::pollData(timeoutInMillis))));
134 return proxy::IQueueImpl::remainingCapacity();
142 bool remove(
const E& element) {
143 return proxy::IQueueImpl::remove(toData(element));
152 return proxy::IQueueImpl::contains(toData(element));
162 std::vector<serialization::pimpl::Data> coll = proxy::IQueueImpl::drainToData();
163 for (std::vector<serialization::pimpl::Data>::const_iterator it = coll.begin(); it != coll.end(); ++it) {
164 std::auto_ptr<E> e = getContext().getSerializationService().template toObject<E>(*it);
165 elements.push_back(*e);
177 size_t drainTo(std::vector<E>& elements,
size_t maxElements) {
178 std::vector<serialization::pimpl::Data> coll = proxy::IQueueImpl::drainToData(maxElements);
179 for (std::vector<serialization::pimpl::Data>::const_iterator it = coll.begin(); it != coll.end(); ++it) {
180 std::auto_ptr<E> e = getContext().getSerializationService().template toObject<E>(*it);
181 elements.push_back(*e);
201 return boost::shared_ptr<E>(toObject<E>(proxy::IQueueImpl::peekData()));
209 return proxy::IQueueImpl::size();
217 return proxy::IQueueImpl::isEmpty();
225 return toObjectCollection<E>(proxy::IQueueImpl::toArrayData());
235 std::vector<serialization::pimpl::Data> list = toDataCollection(elements);
236 return proxy::IQueueImpl::containsAll(list);
245 bool addAll(
const std::vector<E>& elements) {
246 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
247 return proxy::IQueueImpl::addAll(dataList);
257 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
258 return proxy::IQueueImpl::removeAll(dataList);
269 std::vector<serialization::pimpl::Data> dataList = toDataCollection(elements);
270 return proxy::IQueueImpl::retainAll(dataList);
277 proxy::IQueueImpl::clear();
280 IQueue(
const std::string& instanceName, spi::ClientContext *context)
281 : proxy::IQueueImpl(instanceName, context) {
void clear()
Removes all elements from queue.
Definition: IQueue.h:276
bool offer(const E &element, long timeoutInMillis)
Inserts the specified element into this queue.
Definition: IQueue.h:107
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:39
bool offer(const E &element)
Inserts the specified element into this queue.
Definition: IQueue.h:86
std::vector< E > toArray()
Definition: IQueue.h:224
Concurrent, blocking, distributed, observable, client queue.
Definition: RawPointerQueue.h:33
size_t drainTo(std::vector< E > &elements, size_t maxElements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:177
bool contains(const E &element)
Definition: IQueue.h:151
bool removeAll(const std::vector< E > &elements)
Definition: IQueue.h:256
size_t drainTo(std::vector< E > &elements)
Note that elements will be pushed_back to vector.
Definition: IQueue.h:161
int remainingCapacity()
Definition: IQueue.h:133
bool removeItemListener(const std::string ®istrationId)
Removes the specified item listener.
Definition: IQueue.h:74
std::string addItemListener(ItemListener< E > &listener, bool includeValue)
Adds an item listener for this collection.
Definition: IQueue.h:58
boost::shared_ptr< E > poll(long timeoutInMillis)
Definition: IQueue.h:124
int size()
Definition: IQueue.h:208
void put(const E &element)
Puts the element into queue.
Definition: IQueue.h:94
bool isEmpty()
Definition: IQueue.h:216
bool retainAll(const std::vector< E > &elements)
Removes the elements from this queue that are not available in given "elements" vector.
Definition: IQueue.h:268
boost::shared_ptr< E > peek()
Returns immediately without waiting.
Definition: IQueue.h:200
Item listener for IQueue, ISet and IList.
Definition: ItemListener.h:41
bool containsAll(const std::vector< E > &elements)
Definition: IQueue.h:234
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
bool addAll(const std::vector< E > &elements)
Definition: IQueue.h:245
boost::shared_ptr< E > poll()
Returns immediately without waiting.
Definition: IQueue.h:191
boost::shared_ptr< E > take()
Definition: IQueue.h:115